Java Reference
In-Depth Information
for this chapter. For example, I will not tell you what to name your classes
or step you through saving, compiling, and running the programs.
Instead, I will describe a problem to be solved, providing you with all the
details needed to solve the problem.
Keep in mind that there is no correct answer in programming, as long as
you write a program that solves the problem at hand.
The program should take in two integer command-line arguments—
one for the number of peak minutes used, and one for the number
of weekend and night minutes used.
■■
Each customer pays $29.95 a month, which includes 400 peak min-
utes and 750 weekend and night minutes.
■■
The price for going over the allotted time is $.40/minute for both
peak and weekend/night calls.
■■
Lab 3.2: Using if/else
Write the CongratulateStudent program discussed in the section The
switch Statement using if/else statements instead of a switch statement.
Lab 3.3: Summation Problem
Write a program that inputs an integer, n, from the command line and
displays the string “1 + 2 + 3 + 4 + ... + n = sum.” For example, if the
command-line argument is 7, the output should be:
1 + 2 + 3 + 4 + 5 + 6 + 7 = 28
Make sure the number entered on the command line is positive.
Lab 3.4: Using do/while
Write the RandomLoop program from the section The do/while Loop using
a while loop instead of a do/while loop.
Search WWH ::




Custom Search