Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

What info does it need? (6) (40 points) Write a java program to display the properties (freezing, boiling) of the following substances listed in the

What info does it need?image text in transcribedimage text in transcribedimage text in transcribed

(6) (40 points) Write a java program to display the properties (freezing, boiling) of the following substances listed in the table (in Celsius) Substance Freezing Boiling Beer -25 99 water 100 Alcohol -114 -114 78 Oxygen -219 -188 Gold 1064 2856 Note the absolute temperature is -273.15c and the Sun surface temperature is 6000c (+/- a few k). Your program askes the user to enter a temperature (in Celsius) and display the state of each of the substances based on the above table. When the given temperature is between the freezing into solid) and boiling into gas), it is in liquid state. For example, in room temperature (25c) Enter a temp in Celsius At 25.00 Oxygen does not freeze Oxygen boils Beer does not freeze Beer does not boil is in liquid state Alcohol does not freeze Alcohol does not boil is in liquid state Water does not freeze Water does not boil is in liquid state Gold freezes Gold does not boil Enter a temp in Celsius -218 At -218.00 Oxygen does not freeze Oxygen does not boil is in liquid state Beer freezes Beer does not boil Alcohol freezes Alcohol does not boil Water freezes Water does not boil Gold freezes Gold does not boil Enter a temp in Celsius 1065 At 1065.0c Oxygen does not freeze Oxygen boils Beer does not freeze Beer boils Alcohol does not freeze Alcohol boils Water does not freeze Water boils Gold does not freeze Gold does not boil is in liquid state Instead of using a bunch "if-then-else" approach to check the substance boundaries to determine the results, you are asked to analyze and design your program in OO approach using the polymorphic technique that we discussed in class. DON'T use the "tradition if-then-else" approach. You will not score points from using the traditional method. In less than 20 words, explain how you can add another substance (say silver) to your program with minimal changes. (5 points) Hint: - Create a parent class for all the listed substances to derived from as sub-classes. (5 points) o Be sure to have appropriate constructors for the sub-classes. - Create a sub-class (aka child) class for each of the substances (15 points - 3 points each) o Define the corresponding Freeze and Boiling temperatures in the each of sub-class as final double constant variable. o Create constructor to "set" the user-entered temperature. o In each sub-class, write methods to checkFreezel double x) and checkBoil(double x). You want these methods to return Boolean type and have overriding capability to that of the parent. Tuse ---- return (x

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

Prove Equation (5.22).

Answered: 1 week ago