Write A Program To Display The Multiplication Facts For A Number. The User Will Enter A
Write A Program To Display The Multiplication Facts For A Number. The User Will Enter A
You will submit a single zipped IntelliJ project containing your 6 solutions. Do not to use the
proper naming convention for your project, and to include a description of your program
at the top of you Java class, proper indenting, and appropriate comments.
1. Write a program to display the multiplication facts for a number. The user will enter a
value and then a table will be displayed showing the multiplication facts for that
value. Use a while-loop.
Hint: The header (column names and the ----‘s) will be printed prior to entering the while
loop.
Steps.
2. Same as problem #1, but with a for-loop. Write a program to display the
multiplication facts for a number. The user will enter a value and then a table will be
displayed showing the multiplication facts for that value.
Hint: The header (column names and the ----‘s) will be printed prior to entering the
for loop.
Kilograms Pounds
------------------------
1 2.2
3 6.6
5 11.0
7 15.4
9 19.8
11 24.2
13 28.6
15 33.0
17 37.4
19 41.8
Use a for-loop to solve this problem. Additionally, to format your output into the nice
columns, use printf and formatters. See 4.6 on how to format. Table 4.12 explanation
of %10.f is a good hint.
Hint: The header (column names and the ----‘s) will be printed prior to entering the
for loop.
4. Write a program that reads integers greater than zero, and displays the average
and sum of the numbers entered. The program will continue to prompt for
Page 2 of 4
numbers until the user enters a -1, to indicate termination of input. A sample run
is a follows:
Please enter a value (>0) or terminate with -1: 10
Please enter a value (>0) or terminate with -1: 3
Please enter a value (>0) or terminate with -1: 4
Please enter a value (>0) or terminate with -1: -1
The sum is 17
The average is 5.666666666666667
Hint: Recall that to obtain a double value from integer division, you will need to cast
the result to a double.
i.e. 5/3 is a result of 1, but, (double)5/3 is a result of 1.6666666666666667
Hint: You will need to use a sentinel controlled while loop in your solution.
5. Write a program that reads 10 integers and displays the largest value that was
entered. Use a for-loop, do…while loop, or while loop -- your choice.
Enter 10 values:
10 15 25 5 4 12 33 20 22 12
6. Write a program that prompts the user to enter a list of values 1-5 and terminate
input with a 0 (zero). Your program should display the number of 1s 2’s, 3’s, 4’s,
and 5’s that were entered. You will need to use a sentinel controlled while loop.
Do not use arrays in your solutions, but rather a counter for 1’s, 2’s, etc.
Page 3 of 4
5
0
Output
1's 2
2's 3
3's 3
4's 2
5's 1
Page 4 of 4