The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
JavaScript
When user types Y, it calculates the Fahrenheit. when user types N, it still asks for the Fahrenheit.  if user types N again, it gives the Celsius. and then it's complete. I'm missing a loop or there's something off on the loop... but I can't figure out what it is.  Â
Â
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class FinalTemp {
static Scanner scan = new Scanner(System.in);
static String userInput = null;
Â
public static void main(String[] args) throws IOException{
while (true)
{
System.out.println("Do You Want to Continue (Y/N) ?");
userInput = scan.next();
if (userInput.equalsIgnoreCase("Y"));
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please enter temperature in Fahrenheit : ");
double fahrenheit = Double.parseDouble(reader.readLine());
double celsius = (5.0/9.0)*(fahrenheit - 32);
System.out.println("Temperature in Celsius is : "+celsius);
if (userInput.equalsIgnoreCase("N"))
{
System.out.println("HELLO INSTRUCTOR, THIS IS THE INF231 FINAL ASSIGNMENT");
break;
}}}}