In: Computer Science
Write a method with the following header:
public static void showGradeDistribution(int a, int b, int c, int d,
int f)
It should print a graph (using asterisks) for each of the letters entered in the reverse order of the
parameter list and with a label. In addition, if A and B grades sum is equal or exceeds that of grades C
and D and F, the message “Strong class!” should be displayed. For example a method call of:
showGradeDistribution(5,7,4,4,3);
Would print:
A: *****
B: *******
C: ****
D: ****
F: ***
Strong class
Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions. Thank You! =========================================================================== public static void showGradeDistribution(int a, int b, int c, int d, int f) { System.out.print("A: "); for (int star = 1; star <= a; star++) System.out.print("*"); System.out.print("\nB: "); for (int star = 1; star <= b; star++) System.out.print("*"); System.out.print("\nC: "); for (int star = 1; star <= c; star++) System.out.print("*"); System.out.print("\nD: "); for (int star = 1; star <= d; star++) System.out.print("*"); System.out.print("\nF: "); for (int star = 1; star <= f; star++) System.out.print("*"); System.out.println(); if((a+b)>=(c+d+f)){ System.out.println("Strong class!"); } }
===================================================================
public class ExOne { public static void showGradeDistribution(int a, int b, int c, int d, int f) { System.out.print("A: "); for (int star = 1; star <= a; star++) System.out.print("*"); System.out.print("\nB: "); for (int star = 1; star <= b; star++) System.out.print("*"); System.out.print("\nC: "); for (int star = 1; star <= c; star++) System.out.print("*"); System.out.print("\nD: "); for (int star = 1; star <= d; star++) System.out.print("*"); System.out.print("\nF: "); for (int star = 1; star <= f; star++) System.out.print("*"); System.out.println(); if((a+b)>=(c+d+f)){ System.out.println("Strong class!"); } } public static void main(String[] args) { showGradeDistribution(5,7,4,4,3); } }