Answer to Question #2529 in Java | JSP | JSF for zaara
Design and implement a class called Sphere that contains instance data that represents the sphere's diameter. Define the Sphere constructor to accept and initialize the diameter, and include getter and setter methods for the diameter. Include methods that calculate and return the volume and surface area of the sphere (Volume= 3/4 π r3 , area = 4 π r2 ). Include a toString method that returns a one-line
description of the sphere. Create a driver class called MultiSphere, whose main method instantiates and updates several (at least 5) Sphere objects.
2. Shopping cart
Create 3 shopping carts from a Cart class. Each class should have four items in it, a title, a price for the 4 items and the number of each. Your shopping cart should use private variables, so use getter and setter methods to access the items (variables) in your Cart Object. After you have created three Cart objects with four items each, you should print the cart contents. Use a method called displayCart() to make it easier to print out the items for each shopping cart. A sample output for the first cart is given below and you may choose your preferred way to show the output of the 3 carts.
---------- Your Shopping Cart ----------
1. Paper 4.99 3
2. Pencils 1.49 2
3. Pens 2.39 2
4. Printer Ink 39.99 4
Design and implement a class called Flight that represents an airline flight. It should contain instance data that represents the airline name, flight number, and the flight's origin and destination cities. Define the Flight constructor to accept and initialize all instance data. Include getter and setter methods for all instance data. Include a toString method that returns a one-line description of the flight. Create a driver class called FlightTest, whose main method instantiates and updates several (at least 5) Flight objects.
Write a Temperature class that has two instance variables: a temperature value (a floating-point number) and a character for the scale, either C for Celsius or F for Fahrenheit. The class should have a number of constructor methods: one with two parameters for the two instance variables, and a noargument constructor (set to zero degrees Celsius). Include the following:
(1) two accessor methods to return the temperature one to return the degrees Celsius, the other to return the degrees Fahrenheit use the following formulas to write the two methods, and round to the nearest tenth of a degree:
degreesC = 5(degreesF - 32)/9
degreesF = (9(degreesC)/5) + 32
(2) three mutator or set methods: one to set the value, one to set the scale (F or C), and one to set both;
(3) three comparison methods: an equals method to test whether two temperatures are equal, one method to test whether one temperature is greater than another, and one method to test whether one temperature is less than another (note that a Celsius temperature can be equal to a Fahrenheit temperature as indicated by the above formulas); and
(4) a suitable toString method. Then write a driver program (or programs) that tests all the methods. Be sure to use each of the constructors, to
include at least one true and one false case for each of the comparison methods, and to test at least the following temperature equalities: 0.0 degrees C = 32.0 degrees F, -40.0 degrees C = -40.0 degrees F, and 100.0 degrees C = 212.0 degrees F.
6. Team Roster
Create a program called TeamRoster that uses a class called Roster. Roster should contain a team name and the names of all the players on the team written into one string. Use a method called addTeamMember() to append a new member to your roster string. After creating two rosters with more than 5 members.You should indicate the total number of members in each group near the bottom and label each person with an index (e.g. 1,2,3...), print out the team names and their rosters as show below:
Total Members: 7
1. Student 1
2. Student 2
3. Student 3
4. Student 4
5. Student 5
Total Members: 5
7. Gross And Dozens
Design and implement a class called GrossAndDozens to convert a given number of eggs into the number of gross, the number of dozens, and to the number of left over eggs. If you have N eggs, then you have N/12 dozen eggs, with N%12 eggs left. Write a program that asks the user how many eggs he has and then tells the user how many dozen eggs he has and how many extra eggs are left over.
A gross of eggs is equal to 144 eggs. Extend your program so that it will tell the user how many gross, how many dozen, and how many left over eggs he has. For example, if the user says that he has 1342 eggs, then your program would respond with
Your number of eggs is 9 gross, 3 dozen, and 10
since 1342 is equal to 9*144 + 3*12 + 10.
Need a fast expert's response?Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!