Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The idea is to create a class called Temperature used for creating and using objects that will store temperatures (like for weather forecasting programs). You

The idea is to create a class called Temperature used for creating and using objects that will store temperatures (like for weather forecasting programs). You can update the answer as you work about it, and update me in the comments. Here are the instructions:

image text in transcribedimage text in transcribed

image text in transcribedimage text in transcribedThanks for your help!

Requirements: 1) An object of type Temperature should represent a temperature in terms of degrees and scale. Degrees should allow decimal precision (use type double). The three scales possible are Celsius, Fahrenheit, and Kelvin. You may store the scale however you like inside the object, but for any keyboard input or function parameters, scales will come in as type char, where 'C', F, K (as well as the lower case versions) are valid options. Your object must always represent a valid temperature 0 Kelvin represents the lowest possible temperature in existence. Your object should also store a format setting, to be used for display of temperatures to the screen. There will be more than one possible format. The class features (public interface) should work exactly as specified, regardless of what program might be using Temperature objects Conversion: Celsius (Fahrenheit 320 (5/9) (or) Fahrenheit (Celsius *9/5) 32 Celsius Kelvin 273.15 2) Your Temperature class must provide the following services (i.e. member functions) in its public section. These functions will make up the interface of the Temperature class. Make sure you use function prototypes as specified here ou may write any other private functions you feel necessary, but the public interface must include all the functionality described here) the constructor(s): The Temperature class should have a constructor that allows the user to specify the values for the degrees and scale, using types double and char, respectively. If any of the values would result in an invalid temperature, the constructor should throw out the erroneous information and initialize the object to represent 0 Celsius by default. Also, you should allow a Temperature object to be declared without specified parameter values in which case it should initialize to 0 Celsius (the default) Examples: These declarations should be legal, and the comment gives the initialized temperature: emperature t 1 initializes to 0 Celsius initializes to 23.5 Temperature t 2 (23.5 Fahrenheit Temperature t 3 (12.6 invalid scale to 0 Celsius nitial izes 300 this i s below 0 Kelvin initializes to 0 Celsius emperature t4 t5 (1 initializes to 5 Kelvin emperature void Input This function should prompt the user to enter a temperature, and then allow the user to input a temperature from the keyboard. User input is expected to be in the format degrees scale, where degrees allows values with decimal precision, and scale is entered as a character. Whenever the user attempts to enter an invalid temperature, the Input function should display an appropriate error message (like "Invalid temperature. Try again: and make the user re-enter the whole temperature. A few examples of some good and bad inputs 43.6 k 53.5 c 00 F 273.15 c Legal 12.3 -5 K -278 c -500 F last 3 are below absolute zero Illegal You may assume that the user entry will always be of the form D S where D is a numeric value and S is a character

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

Students also viewed these Databases questions