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
**Writing a Driver Program for Method Testing**

**Objective:**
Develop a driver program to test all available methods. Ensure comprehensive testing by invoking each constructor. 

**Instructions:**
1. **Constructor Invocation:**
   - Use each constructor at least once to cover the creation of objects.
   
2. **Comparison Testing:**
   - Include a true case and a false case for every comparison method.
   
3. **Equality Testing:**
   - Test at least these three temperature pairs for equality:
     - Pair 1: 0.0 degrees Celsius and 32.0 degrees Fahrenheit
     - Pair 2: -40.0 degrees Celsius and -40.0 degrees Fahrenheit
     - Pair 3: 100.0 degrees Celsius and 212.0 degrees Fahrenheit

By structuring your program in this way, you ensure that both the constructors and comparison methods are thoroughly validated, guaranteeing reliable performance across various scenarios.
Transcribed Image Text:**Writing a Driver Program for Method Testing** **Objective:** Develop a driver program to test all available methods. Ensure comprehensive testing by invoking each constructor. **Instructions:** 1. **Constructor Invocation:** - Use each constructor at least once to cover the creation of objects. 2. **Comparison Testing:** - Include a true case and a false case for every comparison method. 3. **Equality Testing:** - Test at least these three temperature pairs for equality: - Pair 1: 0.0 degrees Celsius and 32.0 degrees Fahrenheit - Pair 2: -40.0 degrees Celsius and -40.0 degrees Fahrenheit - Pair 3: 100.0 degrees Celsius and 212.0 degrees Fahrenheit By structuring your program in this way, you ensure that both the constructors and comparison methods are thoroughly validated, guaranteeing reliable performance across various scenarios.
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 degrees, one for the scale, one for both the degrees and the scale, and a default constructor. For each of these constructors, assume zero degrees if no value is specified and Celsius 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 formulas 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 temperature is less than another.
Transcribed Image Text: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 degrees, one for the scale, one for both the degrees and the scale, and a default constructor. For each of these constructors, assume zero degrees if no value is specified and Celsius 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 formulas 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 temperature 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