Answered step by step
Verified Expert Solution
Question
1 Approved Answer
[JAVA] Thanks in advance! Create a class called GradeHistogram Copy the code for GradeHistogram given below into the class. Take a few minutes to understand
[JAVA] Thanks in advance!
- Create a class called GradeHistogram
- Copy the code for GradeHistogram given below into the class.
- Take a few minutes to understand what the class does. Besides the mutators and accessors, it has a method called printChart. printChart calls the method printDataRow that prints the asterisks for how many As, Bs, Cs, etc look at output to see what the histogram looks like.
- You will have to write one method in the GradeHistogram class
- The method should be called printDataRow
- It has two formal parameters A string for the row label An int for how many asterisks are in the row
- The method will print The string that was passed in followed by a colon and a space The asterisks (*) After the last asterisk it will print a newline You may want to test the method multiple times in BlueJ before going on. Example: the statement: printDataRow("Number of As", 7); would output the following:
Number of As: *******
Code for class GradeHistogram
public class GradeHistogram { private String className; private int numAs; private int numBs; private int numCs; private int numDs; private int numFs; public GradeHistogram(String className, int numAs, int numBs, int numCs, int numDs, int numFs) { this.className = className; this.numAs = numAs; this.numBs = numBs; this.numCs = numCs; this.numDs = numDs; this.numFs = numFs; } public void setClassName(String name) { className = name; } public void setNumAs(int num) { numAs = num; } public void setNumBs(int num) { numBs = num; } public void setNumCs(int num) { numCs = num; } public void setNumDs(int num) { numDs = num; } public void setNumFs(int num) { numFs = num; } public String getClassName() { return className; } public int getNumAs() { return numAs; } public int getNumBs() { return numBs; }public int getNumCs() { return numCs; }public int getNumDs() { return numDs; }public int getNumFs() { return numFs; } // Write the method printDataRow public void printChart() { System.out.println("Class Name: " + className); printDataRow("Number of As", numAs); printDataRow("Number of Bs", numBs); printDataRow("Number of Cs", numCs); printDataRow("Number of Ds", numDs); printDataRow("Number of Fs", numFs); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started