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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education