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.
8. Simple Calculator
Write a program that will evaluate simple expressions such as 17 + 3 and 3.14159 * 4.7. The expressions are to be typed in by the user. The input always consist of a number, followed by an operator, followed by another number. The operators that are allowed are +, -, *, and /. Your program should read an expression, print its value, read another expression, print its value, and so on. The program should end when the user enters 0 as the first number on the line.
9. Rational Numbers
Rational numbers are numbers that can be represented as a fraction p / q where p is an integer number and q is a positive integer (q != 0). Design and implement a Java class
RationalNumber for representing such numbers. Implement methods to add and mutliply rational numbers. Implement a method for return the value of a rational number as a double value. Write a driver class to test your class. here is the class details:
RationalNumber(int numerator, int denominator)
Creates a new RationalNumber with given numerator and denominator.
RationalNumber add(RationalNumber rationaleNumber)
Adds the given
rationaleNumber to this RationalenNumber (the object that you created
from RationalNumber Class) and returns the sum as a new RationalNumber.
Returns the denominator of this RationalNumber.
Returns the value of this RationalNumber as a double value.
Returns the numerator of this RationalNumber.
RationalNumber multiply(RationalNumber rationalNumber)
Multiplies the given rationalNumber to this RationalNumber (the object that you created from
RationalNumber Class) and returns the product as a new RationalNumber
Your question requires a lot of work and cannot be done for free. Submit it as an assignment to our control panel and we'll assist you.