Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

- Create a base class, Temperature, that has one field, temperature, representing the temperature value using the Kelvin scale. Therefore, the temperature field cannot contain

- Create a base class, Temperature, that has one field, temperature, representing the temperature value using the Kelvin scale. Therefore, the temperature field cannot contain negative values. An attempt to store a negative value will be ignored and the temperature value will not change. The default value of the temperature field (e.g., when creating an object) is 0. The class has a method printTemperature that prints the value of the temperature field. For example:

Temperature is 333.33

- Create a module Conversion that provides conversion between the Kelvin and Celsius values and between the Kelvin and Fahrenheit values.

- Create a derived class HW4 that inherits from the Temperature class and includes the Conversion module. It adds three methods, printKelvin, printCelsius, and printFahrenheit, to print the temperature values (2 decimal places) using the Kelvin, Celsius, and Fahrenheit scales, respectively. For example:

Temperature is 333.33 degrees Kelvin Temperature is 60.18 degrees Celsius Temperature is 140.33 degrees Fahrenheit

- The temperature value can be retrieved/set as using the Kelvin, Celsius, or Fahrenheit scales. An attempt to store a negative value (when converted to the Kelvin scale) will be ignored and the temperature value will not change. The syntax must appear as if there are temperature, celsius, and fahrenheit fields. However, only the temperature field, inherited from theTemperature class, exists. The celsius, and fahrenheit fields are actually methods from the Conversion module. For example:

h = HW6.new() h.temperature = 100 h.celsius = -100 h.fahrenheit = 212

This is going to read a Ruby input file and just print values on the screen.

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

1st Edition

1597496251, 978-1597496254

More Books

Students also viewed these Databases questions

Question

38. What is meant by the term business environment?

Answered: 1 week ago

Question

post the closing entries to income summary and retained Earnings

Answered: 1 week ago