Write class to represent temperatures in degree-fahrenheit

Assignment Help Programming Languages
Reference no: EM1367079

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: EM1367079

Questions Cloud

Calculations of loan fees income : An FI makes a loan commitment of $2,500,000 with an up-front fee of fifty basis points and a back-end fees of 25 basis points on the unused portion of loan. The takedown on the loan is 50 percent.
Write program to compute student-s quiz average : Write a program that will compute student's quiz average. Program must prompt the user for the number of quizzes and then ask the user for each quiz grade.
Connection between demand for goods and market failures : What is significant about the connection between the demand for goods and market failures? What happens to the demand for goods when a market fails
Aggregate demand for goods and services : The Aggregate Demand for goods and services in an economy must at every moment equal the value of Real Gross Domestic Product because both are defined to be the sum of (C+I+G+X-IM).
Write class to represent temperatures in degree-fahrenheit : Write Temperature class to represent temperatures in degrees in Celsius, Fahrenheit and Kelvin. Use floating-point number for temperature and a character (type char) for scale.
Calculating the return on an investment : A 1949 Vincent Black Shadow Series V motorcycle sold for about $45,000 in 1996. If you were fortunate enough to have bought one new for $630 in 1949,
Data in the cancer registries : What is the main purpose behind developing and maintaining this massive collection of data in the cancer registries?
Leakage adjusted money multiplier : Assume the ratio of deposits that banks hold in the form of reserves is 7 percent. Assume further that people want to hold 8 percent of their deposits in the form of cash.
Economic choices-labor shortages : Mention two economic choices you had to make with in last week. Alfred Marshall said in 1890s, "economics is the study of man in ordinary business of life." You must examine one or two of these choices in terms of alternatives you gave up.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write and test code to create window with green background

Use Processing to write and test code that meets the requirements below. Create a 600x400 window with a green background (using 64 as the "amount" of green to draw).

  Create logic for program to enter each household size

Create logic for a program that allows a user to enter each household size and find out the mean and median household size in Marengo.

  Recursive method to read in string of characters

Trying to write a recursive method that reads in a string of characters and checks to see if the first character is either a 'D' or and 'E', then is followed by a string of one or more 'F's.

  Develop a program to input miles driven and gallons for tank

Develop a program in C++ that will input the miles driven and gallons used (both as integers) for each tankful. The program should calculate and display the miles per gallon obtained for each tankful.

  Program to evaluate postfix expressions using a stack

Program to evaluate postfix expressions containing complex numbers using a stack. This program should contain two classes. T

  Create program to calculate amount of paint needed

Create a program to calculate the amount of paint needed to cover one side of a house with a sloped roof . Assume tha this house has a rectangular shape with a rectangular window .

  Create class for factory workers are paid certain amount

Create class for Factory workers are paid a certain amount for each unit they make and their total pay is the number of units produced times the pay per unit.

  Pseudocode to create thread-safe countdownevent by locks

Write pseudocode to implement a thread-safe CountdownEvent using locks and condition variables by implementing the following methods (lists 4 methods) and then "implement a Barrier using a CountdownEvent.

  Design program to asks for number of fat grams

Design a program that asks for the number of fat grams and calories in a food item. Validate the input as follows: Make sure the number of fat grams and calories are not less than 0.

  Explain relationship between xbrl and semantic web

How do HTML 5, RDF (Resource Description Framework), and OWL (Web Ontology Language) relate to the semantic web? Explain the relationship between XBRL and the semantic web.

  Creating loop to find number of items bought based on price

Make a block using a loop that will find the number of items that can be bought based on the price of the item and the total amount available to spend.

  Create program to calculate and display number of miles

Create a program to calculate and displays the number of miles per hour over the speed limit that a speeding driver was doing. The program should ask for the speed limit and the drivers speed.

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