Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Debugging help1 for Fahrenheit to Celsius 2 for Celsius to Fahrenheit 3 to quit: 1 Enter the degrees in Fahrenheit: 75 The temp in Celsius

Debugging help1 for Fahrenheit to Celsius 2 for Celsius to Fahrenheit 3 to quit: 1 Enter the degrees in Fahrenheit: 75 The temp in Celsius is 23.9 1 for Fahrenheit to Celsius 2 for Celsius to Fahrenheit 3 to quit: 2 Enter the degrees in Celsius: 23 The temp in Fahrenheit is 73.4 1 for Fahrenheit to Celsius 2 for Celsius to Fahrenheit 3 to quit: 3 Process completed.

import java.util.Scanner; public class Temperature { public static void main( String args[] ) { int option; int degree1; int celsius1; int fahrenheit1; Scanner input = new Scanner( System.in ); option = 0; While ( option != 3 ) System.out.printf( "%s %s %s ", "1 for Fahrenheit to Celsius", "2 for Celsius to Fahrenheit", "3 to quit:" ); option = input.nextDouble(); System.out.println( "Enter the degrees in Fahrenheit: " ); degree1 = input.nextDouble(); celsius1 = ( degree1 - 32 ) * 5 / 9; System.out.printf( "The temp in Celsius is %d ", celsius1 ); if ( option == 2 ); System.out.println( "Enter the degrees in Celsius: " ); degree1 = input.nextDouble(); fahrenheit1 = ( degree1 * 9 / 5 ) + 32; System.out.printf( "The temp in Fahrenheit is %d ", fahrenheit1 ); } // end while loop } // end method Main } // end class Temperature

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