class Student
{
//declare instance variables
private String name;
private int average;
private double gpa;
//default constructor
public Student()
{
name=" ";
average=0;
gpa=0.0;
}
//parameterized constructor
public Student(String name,int average,double gpa)
{
setName(name);
setAverage(average);
setGpa(gpa);
}
//accessor and mutators
public void setName(String name)
{
this.name=name;
}
public String getName()
{
return this.name;
}
public void setAverage(int average)
{
this.average=average;
}
public int getAverage()
{
return this.average;
}
public void setGpa(double gpa)
{
this.gpa=gpa;
}
public double getGpa()
{
return this.gpa;
}
//check objects are equal or not
public boolean equals(Student s)
{
if(getName().equals(s.getName()) &&
getAverage()==s.getAverage() && getGpa()==s.getGpa())
return true;
else
return false;
}
public String toString()
{
return "Name ="+getName()+" ,Average= "+getAverage()+" ,GPA=
"+getGpa()+", Grade= "+calculateGrade();
}
public String calculateGrade()
{
int avg=getAverage();
if(avg>=90 && avg<=100)
return "A";
else if(avg>=85 && avg<=89)
return "B+";
else if(avg>=80 && avg<=84)
return "B";
else if(avg>=75 && avg<=79)
return "C+";
else if(avg>=70 && avg<=74)
return "C";
else if(avg>=65 && avg<=69)
return "D+";
else if(avg>=60 && avg<=64)
return "D";
else
return "F";
}
}
write a class encapsulating the concept of a student assuming that the student has the following...
Write a class encapsulating the concept of a television set, assuming a television set has the following attributes: a brand and a price. include a constructor, the accessors and mutators, and methods to string and equals. Write a client class to test all the methods in your class.
Using Java Write a class encapsulating the concept of student grades (50 elements) on a test, assuming student grades are composed of a list of integers between 0 and 100. Write the following methods: A constructor with just one parameter, the number of students; all grades can be randomly generated Accessor, mutator, toString, and equals methods A method returning the highest grade A method returning the average grade A method returning the lowest grade Write a client class to test...
[CODE] Write a class encapsulating the concept of a house, assuming a house has the following attributes: value (in dollars), a city location, and number of bedrooms. Your class name should be “House” and your code should be in a file called “House.java”. You will need to create this file. In this class, include: Private instance variables for the previously-mentioned attributes A default constructor An overloaded constructor Accessor and mutator methods (i.e., get and set methods) The toString method The...
Write a class Store which includes the attributes: store name, city. Write another class encapsulating an Art Gallery, which inherits from Store. An Art Gallery has the following additional attributes: how many paintings are sold every year and the number of artists submitting artwork. Code the constructor, accessors, mutators, toString and equals method of the super class Store. Code the constructor, accessors and mutators for the subclass Art Gallery. In the Art Gallery class, also code a method returning the...
Write a class encapsulating the concept of a vendor, if a vendor has the following attributes: company name, id, array of quarterly purchase order totals (4 double elements). Include a constructor, accessor, mutator, and toString methods. Also code the following methods: one returning the total purchase orders (total all array elements) and a method to modify an array element (change the value of an array element). Write a client class to create 2 vendor objects and test all your methods.
IN JAVA Write a class Store which includes the attributes: store name, city. Write another class encapsulating an Art Gallery, which inherits from Store. An Art Gallery has the following additional attributes: how many paintings are sold every year and the number of artists submitting artwork. Code the constructor, accessors, mutators, toString and equals method of the super class Store. Code the constructor, accessors and mutators for the subclass Art Gallery. In the Art Gallery class, also code a method...
In Java, Write a class encapsulating a restaurant,which inherits from Store. A restaurant has the following additional attributes: how many people are served every year and the average price per person. code the constructor, accessors, mutators, toString and equals method of the new subclass; also code a method returning the average taxes per year. You also need to include a client class to test your code for both the parent class and the subclass. Code for Store below(Super class aka...
Create the following program in java please Write a class Store which includes the attributes: store name and sales tax rate. Write another class encapsulating a Book Store, which inherits from Store. A Book Store has the following additional attributes: how many books are sold every year and the average price per book. Code the constructor, accessors, mutators, toString and equals method of the super class Store and the subclass Book Store; In the Book Store class, also code a...
Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the concept of a college course, assuming that a course has following attributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include a constructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test the behavior of the class and its methods. The outline of the class is given as follows: public class Course...
Write a class encapsulating the concept of daily temperatures for a week with a single dimensional array of temperatures. Write the following methods: • A constructor accepting an array of seven temperatures as a parameter. • Accessor, mutator, toString() and equals() methods • A method returning how many temperatures were below freezing. • A method returning an array of temperatures above 100 degrees. • A method returning the largest change in temperature between any two consecutive days. • A method...