Write a Java program that performs the following:
- Represent Pass/Fail distribution for a course grades as a bar graph. The program should prompt the user to enter either P for pass or F for fail, to stop the user enters S.
- After the user enters S, the program calculates and displays the grade distribution as shown in the example below.
- In the example the user entered 6 grades : 4 Ps and 2 Fs. The P and F bars represent these percentages. The number of asterisks * printed are ratio x 50. For passing grades it is calculated as (4/6) x 50 = 33.33, which means 33 asterisks are printed, and for failing grades it is calculated as (2/6) x 50 = 16.7, which means 16 asterisks will printed.
- To print the numbers of the scale (0,10,20, … 100), you can use printf() with the format specifier %5s or %5d for each number. The same applies to the bars “|”.
Running Example:
Please enter P for Pass, F for Fail or S to stop P
Please enter P for Pass, F for Fail or S to stop F
Please enter P for Pass, F for Fail or S to stop P
Please enter P for Pass, F for Fail or S to stop F
Please enter P for Pass, F for Fail or S to stop P
Please enter P for Pass, F for Fail or S to stop P
Please enter P for Pass, F for Fail or S to stop S
0 10 20 30 40 50 60 70 80 90 100%
| | | | | | | | | | |
********************************* P
**************** F