JAVA programming

0 comments

All input and output using dialog boxes. Nothing on the command line, or your grade will
be 0.
 Divide your program into parts
o Between each part of your program, put a comment that says which part
it is
 Declaration of variables
o Declare your variables for each part at the beginning of that part.
o For example, declare your variables for part 1 at the beginning of part 1;
declare your variables for part 2 at the beginning of part 2; etc
 It is very important to
o Use meaningful variable names
o indent your code properly
o use brackets and line them up
o comment your ending brackets, for example
 // end class
 // end main
 // end if
 Part 1
Write a while loop that says I love while loops ten times, like this:
1. I love while loops.
2. I love while loops.
3. I love while loops.
etc
etc.
10. I love while loops.
The entire output shown above should appear in ONE dialog box.
Write a do … while loop that says I love do .. while loops ten times, like this:
1. I love do … while loops.
2. I love do … while loops.
3. I love do … while loops.
etc
etc
10. I love do .. while loops.
The entire output shown above should appear in ONE dialog box. The lines are
numbered, 1 through 10. Don’t skip a line between each line of output.
 Part 3
Write a for loop that says I love for loops ten times, like this:
1. I love for loops.
2. I love for loops.
3. I love for loops.
etc
etc
10. I love for loops.
The entire output shown above should appear in ONE dialog box. The lines are
numbered, 1 through 10. Don’t skip a line between each line of output.
 Part 4
Use a while loop to display, in one dialog box, the multiplication table for 7,
from 1 through 70, in ONE dialog box
o the first time through the loop, mulitply 7 times 1
o the second time through the loop, mulitply 7 times 2
o the third time through the loop, muliply 7 times 3
o etc
o the last time through the loop, multiply 7 times 10
o so the output will contain ten lines and will look like this:
7 times 1 is: 7
7 times 2 is: 14
7 times 3 is: 21
7 times 4 is: 28
etc
etc
7 times 10 is: 70
 Part 5
Use a while loop to display the multiplication table for any number that
the user enters. First, ask the user to enter a number. Then, display the
times table for the number the user enters. For example, if the user enters
7, the output will look like this:
7 times 1 is: 7
7 times 2 is: 14
7 times 3 is: 21
7 times 4 is: 28
etc
etc
7 times 10 is: 70
However, if the user enters 5, the output will look like this:
5 times 1 is: 5
5 times 2 is: 10
5 times 3 is: 15
5 times 4 is: 20
etc
etc
5 times 10 is: 50
 Part 6
o Use a do .. while loop to write the following in one dialog box. Initialize
your count variable to 10 (this means assign it a value of 10) before you
begin the loop. Notice that proper English grammar requires that we say
one bottle (no “s” on bottle).
10 bottles of beer on the wall.
9 bottles of beer on the wall.
8 bottles of beer on the wall.
7 bottles of beer on the wall.
etc
etc
1 bottle of beer on the wall.
0 bottles of beer on the wall.
 Part 7
Use one and only one for loop to print the following pattern in one dialog box.
Do not use nested for loops. Use only one for loop, not two or more. Do not use
any other kind of loop. Do not use a switch/case statement or if conditions. The
same code should work for 7 lines of asterisks or 17 lines of asterisks, simply
by changing the number of times the loop executes, from 7 to 17.
*
**
***
****
*****
******
*******
Hint: there are seven lines of output, so you should loop seven times. Use the
power of String concatenation. Do not simply literally write the output like this:
message = “*n**n***n****n*****n******n*******”;
 Part 8
Ask the user how many quizzes he took. Then, prompt the user for that many
grades. When the user is done entering the grades, tell him his average grade
for all his quizzes. For example, if the user says he took three quizzes, prompt
the user for three grades, then tell the user the average of those three grades. Of
course, you don’t know what number the user will enter!
When you prompt the user for quiz grades, be polite. For example, if the user
says he took 3 quizzes, the prompts should say: “Enter quiz grade 1: “, then
Enter quiz grade 2: “, then “Enter quiz grade 3: ”
 Part 9
o display a message to a dialog box that says: Goodbye from _____ . (Fill
in the blank with your full name.
 Sumit AssignmentSix as follows
o Submit the .java file in Blackboard
o Do NOT submit the .class file. Submit only the .java file
o I do not give credit for work that does not compile. If you have problems
with compiling, email me your .java file and tell me in the body of the
email what the compiler error is, exactly.

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}