For the Java code below, you will demonstrate the ability to use and call multiple methods in your program.  Using the code below, create the following methods: 1. A method that converts the temperature from Fahrenheit to Celsius.  The method should be passed a parameter - Fahrenheit and should return a result - Celsius. 2. A method to output the results of your temperature conversion.  The method should be passed 2 parameters - temperature in Fahrenheit and the temperature in Celsius. Finally, place an edit in your code to ensure that the user only enters a numeric value. Your output should appear as follows: Enter the Fahrenheit temperature you want to convert: 212 This converts to 100 Celsius Do you want to convert another temperature – Y or N? Y Enter the Fahrenheit temperature you want to convert: 100 This converts to 37.8 Celsius Do you want to convert another temperature – Y or N? N The program has ended

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
100%

For the Java code below, you will demonstrate the ability to use and call multiple methods in your program.  Using the code below, create the following methods:

1. A method that converts the temperature from Fahrenheit to Celsius.  The method should be passed a parameter - Fahrenheit and should return a result - Celsius.

2. A method to output the results of your temperature conversion.  The method should be passed 2 parameters - temperature in Fahrenheit and the temperature in Celsius.

Finally, place an edit in your code to ensure that the user only enters a numeric value.

Your output should appear as follows:

  • Enter the Fahrenheit temperature you want to convert:
  • 212
  • This converts to 100 Celsius
  • Do you want to convert another temperature – Y or N?
  • Y
  • Enter the Fahrenheit temperature you want to convert:
  • 100
  • This converts to 37.8 Celsius
  • Do you want to convert another temperature – Y or N?
  • N
  • The program has ended

import java.text.DecimalFormat;
import java.util.Scanner;

public class CS1210

{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
DecimalFormat df = new DecimalFormat("#.#");
char choice;

do
{
System.out.print("Enter the Fahrenheit temperature you want to convert: ");
double fahrenheit = input.nextDouble();

double celsius = ((fahrenheit - 32.0) / 1.8);
System.out.println("This converts to " + df.format(celsius) + " Celsius");

System.out.println("Do you want to convert another temperature – Y or N?");
choice=input.next().charAt(0);
}

while (choice == 'Y');
System.out.println("The program has ended");

}

}

1 // This Java code converts Fahrenheit to Celcius.
2
30 import java.text.DecimalFormat;
4 import java.util.Scanner;
6 public class CS1210
7
8 {
public static void main(String[] args)
{
Scanner input
10
C611
12
13
14
15
16
17
= new Scanner(System.in);
= new DecimalFormat("#.#");
DecimalFormat df :
char choice;
do
{
System.out.print("Enter the Fahrenheit temperature you want to convert: ");
18
double fahrenheit
input.nextDouble();
19
20
21
22
23
24
25
26
27
double celsius =
((fahrenheit - 32.0) / 1.8);
System.out.println("This converts to
+ df.format(celsius) +
Celsius");
Y or N?");
System.out.println("Do you want to convert another temperature
choice=input.next().charAt(0);
}
'Y');
while (choice
System.out.println("The program has ended");
==
28
29
30
}
31 }
32
A Problems @ Javadoc E Declaration E Console X
CS1210 [Java Application] C:\Users|Victor\AppData\Local\Temp\eoiBDB9.tmp\plugins\org.eclipse.justj.openjdk.hotspot.jre.minimal
Enter the Fahrenheit temperature you want to convert:
Transcribed Image Text:1 // This Java code converts Fahrenheit to Celcius. 2 30 import java.text.DecimalFormat; 4 import java.util.Scanner; 6 public class CS1210 7 8 { public static void main(String[] args) { Scanner input 10 C611 12 13 14 15 16 17 = new Scanner(System.in); = new DecimalFormat("#.#"); DecimalFormat df : char choice; do { System.out.print("Enter the Fahrenheit temperature you want to convert: "); 18 double fahrenheit input.nextDouble(); 19 20 21 22 23 24 25 26 27 double celsius = ((fahrenheit - 32.0) / 1.8); System.out.println("This converts to + df.format(celsius) + Celsius"); Y or N?"); System.out.println("Do you want to convert another temperature choice=input.next().charAt(0); } 'Y'); while (choice System.out.println("The program has ended"); == 28 29 30 } 31 } 32 A Problems @ Javadoc E Declaration E Console X CS1210 [Java Application] C:\Users|Victor\AppData\Local\Temp\eoiBDB9.tmp\plugins\org.eclipse.justj.openjdk.hotspot.jre.minimal Enter the Fahrenheit temperature you want to convert:
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
void method
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