Write a driver program that tests all the methods. Be sure to invoke each of the constructors, to include at least one true and one false case for each comparison method, and to test at least the following three temperature pairs for equality: 0.0 degrees C and 32.0 degrees F, –40.0 de- grees C and –40.0 degrees F, and 100.0 degrees C and 212.0 degrees F.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Write a driver program that tests all the methods.
Be sure to invoke each of the constructors, to
include at least one true and one false case for
each comparison method, and to test at least
the following three temperature pairs for equality:
0.0 degrees C and 32.0 degrees F, -40.0 de-
grees C and -40.0 degrees F, and 100.0 degrees
C and 212.0 degrees F.
Transcribed Image Text:Write a driver program that tests all the methods. Be sure to invoke each of the constructors, to include at least one true and one false case for each comparison method, and to test at least the following three temperature pairs for equality: 0.0 degrees C and 32.0 degrees F, -40.0 de- grees C and -40.0 degrees F, and 100.0 degrees C and 212.0 degrees F.
7. Write a Temperature class that represents
temperatures in degrees in both Celsius and
Fahrenheit. Use a floating-point number for the
temperature and a character for the scale: either
'C' for Celsius or 'F' for Fahrenheit. The class
should have
· Four constructors: one for the number of de-
grees, one for the scale, one for both the de-
grees and the scale, and a default construc-
tor. For each of these constructors, assume
zero degrees if no value is specified and Cel-
sius if no scale is given.
· Two accessor methods: one to return the
temperature in degrees Celsius, the other to
return it in degrees Fahrenheit. Use the for-
mulas from Practice Program 5 of Chapter
3
and round to the nearest tenth of a
degree.
• Three set methods: one to set the number of
degrees, one to set the scale, and one to set
both.
• Three comparison methods: one to test
whether two temperatures are equal, one to
test whether one temperature is greater than
another, and one to test whether one temper-
ature is less than another.
Transcribed Image Text:7. Write a Temperature class that represents temperatures in degrees in both Celsius and Fahrenheit. Use a floating-point number for the temperature and a character for the scale: either 'C' for Celsius or 'F' for Fahrenheit. The class should have · Four constructors: one for the number of de- grees, one for the scale, one for both the de- grees and the scale, and a default construc- tor. For each of these constructors, assume zero degrees if no value is specified and Cel- sius if no scale is given. · Two accessor methods: one to return the temperature in degrees Celsius, the other to return it in degrees Fahrenheit. Use the for- mulas from Practice Program 5 of Chapter 3 and round to the nearest tenth of a degree. • Three set methods: one to set the number of degrees, one to set the scale, and one to set both. • Three comparison methods: one to test whether two temperatures are equal, one to test whether one temperature is greater than another, and one to test whether one temper- ature is less than another.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY