The Temperature class is an abstract class with two abstract methods. Create the Conversion class which inherits from Temperature. Use the formulas below to help with the temperature conversions.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question

The Temperature class is an abstract class with two abstract methods. Create the Conversion class which inherits from Temperature. Use the formulas below to help with the temperature conversions.

CODE:

abstract class Temperature {
  public abstract double celsius(double temp);
  public abstract double fahrenheit(double temp);
}

//add class definitions below this line

 

//add class definitions above this line

public class Exercise3 {  
  public static void main(String[] args) {
    
    //add code below this line

     Conversion c = new Conversion();
    
    //add code above this line
  }
}

Polymorphis. x
Collapse Polymorphism -> Coding Exercises - Polymorphism
Polymorphism Exercise 3
Calling the convertTo method with the following arguments
should produce the return values in the table below. Note,
capitalization for the string argument should not affect the
output.
Method Call
Return Value
c.convertTo("Celsius", 212.0)
100
c.convertTo("CELSIUS", 78.0)
25.555555555555554
c.convertTo("celsius", 23.0)
-5.0
c.convertTo("Fahrenheit", 0.0)
32.0
c.convertTo("FAHRENHEIT", 29.0)
84.2
c.convertTo("fahrenheit", 112.8)
233.6
TRY IT
Transcribed Image Text:Polymorphis. x Collapse Polymorphism -> Coding Exercises - Polymorphism Polymorphism Exercise 3 Calling the convertTo method with the following arguments should produce the return values in the table below. Note, capitalization for the string argument should not affect the output. Method Call Return Value c.convertTo("Celsius", 212.0) 100 c.convertTo("CELSIUS", 78.0) 25.555555555555554 c.convertTo("celsius", 23.0) -5.0 c.convertTo("Fahrenheit", 0.0) 32.0 c.convertTo("FAHRENHEIT", 29.0) 84.2 c.convertTo("fahrenheit", 112.8) 233.6 TRY IT
Exercise3.java
Polymorphis. x
abstract class Temperature {
public abstract double celsius (double temp);
1
Collapse
Polymorphism -> Coding Exercises - Polymorphism
public abstract double fahrenheit(double temp);
}
4
Polymorphism Exercise 3
5
//add class definitions below this line
7
8
Exercise 3
9
10
//add class definitions above this line
11
The Temperature class is an abstract class with two abstract
public class Exercise3 {
public static void main (String[] args) {
12 -
13 ,
methods. Create the Conversion class which inherits from
14
//add code below this line
Temperature. Use the formulas below to help with the
15
16
temperature conversions.
17
18
Convert Fahrenheit to Celsius
//add code above this line
}
}
19
20
21
°F – 32
C =
1.8
Convert Celsius to Fahrenheit
°F = °C * 1.8+ 32
Expected Output
Instantiate a Conversion object.
//add code below this line
0% (1:0)
Java
Transcribed Image Text:Exercise3.java Polymorphis. x abstract class Temperature { public abstract double celsius (double temp); 1 Collapse Polymorphism -> Coding Exercises - Polymorphism public abstract double fahrenheit(double temp); } 4 Polymorphism Exercise 3 5 //add class definitions below this line 7 8 Exercise 3 9 10 //add class definitions above this line 11 The Temperature class is an abstract class with two abstract public class Exercise3 { public static void main (String[] args) { 12 - 13 , methods. Create the Conversion class which inherits from 14 //add code below this line Temperature. Use the formulas below to help with the 15 16 temperature conversions. 17 18 Convert Fahrenheit to Celsius //add code above this line } } 19 20 21 °F – 32 C = 1.8 Convert Celsius to Fahrenheit °F = °C * 1.8+ 32 Expected Output Instantiate a Conversion object. //add code below this line 0% (1:0) Java
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT