Write class to represent temperatures in degree and celsius

Assignment Help Programming Languages
Reference no: EM1364350

Write a Temperature class that represents temperatures in degrees in Celsius, Fahrenheit and Kelvin. Use a floating-point number for the temperature and a character (type char) for the scale: 'C' for Celsius, 'F' for Fahrenheit and 'K' for Kelvin. The class should have

a) Four constructors: one for the degrees, one for the scale, one for both the degrees and scale, and a no-argument constructor. For each of these constructors, assume zero degrees if no value is specified and Celsius if no scale is given.
b) Three accessor methods: one to return the temperature in degrees Celsius, one to return the temperature in degrees Fahrenheit, one to return the temperature in degrees Kelvin.

For conversion between scales you can use the following formulas:
Celsius = 5/9 x (Fahrenheit - 32)
Kelvin = Celsius + 273.15

c) Three set methods: one to set the temperature, one to set the scale and one to set both.
d) Three comparison methods: one to test whether two temperatures are equal, one to test whether one temperature is greater than the other and one to test whether one temperature is less than the other.
e) a toString method: to display the temperature and scale. The output should look like 32° C (You can copy the degree sign from here to put in your code)

Write a test program to demonstrate your class. Be sure to use all of your methods in the test program.

Reference no: EM1364350

Questions Cloud

Describe in details of the social responsibilities : Explain the communication and Recommend one way the organization can improve its social responsibility. Describe in details of the social responsibilities.
How fast does it move after the bullet emerges : David is driving a steady 24 when he passes Tina, who is sitting in her car at rest. Tina begins to accelerate at a steady 2.70 at the instant while David passes. How far does Tina drive before passing David.
Explain what forces are driving changes : Explain What forces are driving changes in the movie rental industry and are the combined impacts of these driving forces likely to be favorable
Calculate and graph the money growth rate : As a junior financial analyst in a brokerage firm, you have been asked by your boss to show the usefulness of the World Wide Web as a convenient resource for financial research.
Write class to represent temperatures in degree and celsius : Write a Temperature class that represents temperatures in degrees in Celsius, Fahrenheit and Kelvin. Use a floating-point number for the temperature and a character (type char) for the scale.
Licensing of health care professionals : Physicians and nurses are required by states to meet specific licensing requirements before providing care to the public; however, other health care workers are required to be licensed.
Organizing and delegating in a shoe store : A note to call Mary (salesclerk) about vacation schedule and a notice that the mall will be changing hours for the upcoming holiday and requesting notice of store plans.
Explain how would the bonus distribution : Explain How would the bonus distribution to the four managers (new car, used car, service and parts) change for the deal described in the case
What good or service does the firm sell : What good or service does the firm sell and How should the firm alter the price of the good or service to increase revenues?

Reviews

Write a Review

Programming Languages Questions & Answers

  Write statement essential to call compute interest method

Write statement essential to call the calculate interest method with an account balance of $2300.00 and an interest rate of 5%. What rule must be adhered to when calling a method with multiple parameters?

  Create an abstract representation of a generic animal

Create an abstract representation of a generic Animal that has the at least two polymorphic methods for making a sound and showing the image of the animal.

  Program calculate average number of days employee are absent

Write a program that calculates the average number of days a company's employees are absent. The program should have the following functions: a function called main that asks the user for the number of employees.

  Program to ask how many games are being purchased

Your program should ask the store clerk how many games are being purchased and calculate a total due (with 6% tax). The total number of games, the discount amount.

  Input number by user and display positive and negative

Input a number entered by the user and display "positive" if it is greater than zero, "negative" if it is less than zero, and "zero" if it is equal to zero.

  Program to solve roots of quadratic equation

Write down a program which solves the roots of the quadratic equation of the given form:- ax 2 + bx + c = 0. Display the results on screen.

  Create a multi-threaded competition

Create a multi-threaded competition in which opposing Robin Hoods will attack one another and try to take each other's gold coins.

  Prolog program to reads employee-s number

Write a prolog program that reads an employee's number from the keyboard, number of hours worked and an hourly rate of pay.

  Design a flowchart displays item-s data

Design a flowchart or pseudocode for the following: displays the item's data only if it is a best-selling item. Best-selling items are those that sell more than 2000 pounds per month.

  Write program to simulate bank transaction

Write a program to simulate a bank transaction. There are two bank accounts: checking and savings. First, ask for the initial balances of the bank accounts.

  Program which calculate and displays fifteen percent tip

Write a program which calculate and displays a 15 percent tip when the price of a meal is input by the user. (Hint: the tip is computed by multiplying the price of the meal by 0.15.).

  Display policy data after revisions have made

The day is not correct for the month (that is, between 1 and 31 for January, 1 and 29 for February, and so on), then set the month, day, and year to 0. Display the policy data after any revisions have been made.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd