Question: Question set 1 (Java) object oriented: 1.Write a class called Student. The class should be able to store information regarding the name, age, gpa, and
Question set 1 (Java) object oriented:
1.Write a class called Student. The class should be able to store information regarding the name, age, gpa, and phone number of a Student object. Please write all the setter and getter methods. Finally, write a Demo class to demonstrate the use of the class by creating two different objects.
2.Use the same Student class from the previous problem. This time,you will write a different Demo class, in which you will create three Student objects. You will store these three objects in a Student array that can hold up to 10 Student objects. Write another method in the Demo class called show Students(). This method, when called from the main method, will show all the student information, one object at a time, in the array on the console.
3.Write a class called Cat. The class should have two variables to store data regarding the name (String type) and weight (double type) of each Cat object. All cat objects will have a weight of 15 ounces when born (upon creation). Write the getter and setter methods. In addition, write a method called feed(int foodAmount). The feed method will allow the user to enter the amount of food fed to the cat object. The weight of the cat will increase by 1 ounce for 10 ounces of food is fed to the cat.Now write a Demo class, in which you will create a Cat object. Give the cat a name and feed the cat 5 times by calling the feed method five times in a row. Each time the food amount fed is a random integer number between 5 to 15 ounces. Display the name and final weight in pounds and ounces of the cat.
4.Write a Book class that contains book title and book price information. Write a Demo class in which you will create 1000 books. Each book title is made of a String composed of 5 to 10 random uppercase letters. Each book price is made of a random double value ranging from 0.00 to 99.99. Print these books in a nice formatted table of three columns on the console. The first column contains serial numbers from 1 to 1000. The second column contains book titles, and the third column contains their matching book prices with two decimal places.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
