You will have to write one method in the GradeHistogram class
The Code:
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)
{
//printing the string first
System.out.print(rowLabel+": ");
//simple for loop to print the asterisks
for(int i=1;i<=numAst;i++){
System.out.print("*");
}
//new line character after all the asterisks
System.out.println();
}
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);
}
//main method has been added to test the functions
public static void main(String args[]) {
//Creating object to call the method
printChart()
GradeHistogram ob = new
GradeHistogram("CheggIs<3",1,2,3,4,5);
ob.printChart();
}
}
Console Output:

You will have to write one method in the GradeHistogram class The method should be called...
Thank you in advance. Create a class called Main and write the main method. I need help with calling the printChart method Declare a variable to hold the grade as it is read in Declare 5 variables to hold counts to count the number of As, Bs, Cs, etc declare a variable to hold the class name and ask the user to enter the name of the class whose grades are going to be entered. Write a loop that reads...
Java help: 1.1) Create a class TA that extends class Student. 1.2) Add a variable to the TA class to represent the course the student is TA'ing. 1.3) Provide a constructor for the class so the code in the PeopleFactory will work as provided. 1.4) Provide a toString() method for the TA class so that TA's will output as shown in the sample code. Provide a class Staff so that you can un-comment the lines of code in the PeopleFactory class that...
Write a getCount method in the IntArrayWorker class that returns the count of the number of times a passed integer value is found in the matrix. There is already a method to test this in IntArrayWorkerTester. Just uncomment the method testGetCount() and the call to it in the main method of IntArrayWorkerTester. Write a getLargest method in the IntArrayWorker class that returns the largest value in the matrix. There is already a method to test this in IntArrayWorkerTester. Just uncomment...
In java 8. Modify the averageTopSpeed() method (in the class FormulaOne) using only lambdas and streams and print it to the terminal via the driver class: import java.util.*; public class Racer implements Comparable { private final String name; private final int year; private final int topSpeed; public Racer(String name, int year, int topSpeed){ this.name = name; this.year = year; this.topSpeed = topSpeed; } public String toString(){ return name + "-" + year + ", Top...
Java 1. Write a getCount method in the IntArrayWorker class that returns the count of the number of times a passed integer value is found in the matrix. There is already a method to test this in IntArrayWorkerTester. Just uncomment the method testGetCount() and the call to it in the main method of IntArrayWorkerTester. 2. Write a getLargest method in the IntArrayWorker class that returns the largest value in the matrix. There is already a method to test this in...
java This lab is intended to give you practice creating a class with a constructor method, accessor methods, mutator methods, equals method , toString method and a equals method. In this lab you need to create two separate classes, one Student class and other Lab10 class. You need to define your instance variables, accessor methods, mutator methods, constructor, toString method and equals method in Student class. You need to create objects in Lab10 class which will have your main method...
ble and instance variable, and then use clas 4. Please discuss the difference between class variable and instant variable to complete the following code for the count of number of stud public class Student _//q1: fill this line to create a class variable num. public Student 1/ 22: fill this line to increase num. public static int getNum() return num; public static void main(String[] args) { Student stl=new Student O; Student st2-new Student ; Student st3-new Student ; //q3: fill...
Using your Dog class from earlier this week, complete the following: Create a new class called DogKennel with the following: Instance field(s) - array of Dogs + any others you may want Contructor - default (no parameters) - will make a DogKennel with no dogs in it Methods: public void addDog(Dog d) - which adds a dog to the array public int currentNumDogs() - returns number of dogs currently in kennel public double averageAge() - which returns the average age...
I need a shoppingcartmanager.java that contains a main method for this code in java Itemtopurchase.java public class ItemToPurchase { // instance variables private String itemName; private String itemDescription; private int itemPrice; private int itemQuantity; // default constructor public ItemToPurchase() { this.itemName = "none"; this.itemDescription = "none"; this.itemPrice = 0; this.itemQuantity = 0; } public ItemToPurchase(String itemName, int itemPrice, int itemQuantity,String itemDescription) { ...
I have a little problem about my code. when i'm working on "toString method" in "Course" class, it always say there is a mistake, but i can not fix it: Student class: public class Student { private String firstName; private String lastName; private String id; private boolean tuitionPaid; public Student(String firstName, String lastName, String id, boolean tuitionPaid) { this.firstName=firstName; this.lastName=lastName; this.id=id; this.tuitionPaid=tuitionPaid; } ...