Question: 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
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 Example: the statement: printDataRow("Number of As", 7); would output the following Number of As: *******
- The class GradeHistogram is:
- 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; } public void printDataRow(String rowLabel, int numAst) { //answer goes here } 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
