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.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F61bcadc8-3e93-4502-9ac4-4c9e550795e3%2Feb28c52f-548a-478b-aae0-87508630b6df%2Fhzi9o1_processed.png&w=3840&q=75)
![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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F61bcadc8-3e93-4502-9ac4-4c9e550795e3%2Feb28c52f-548a-478b-aae0-87508630b6df%2Fg4s4qy_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)