-1

This is for a class and I can't figure out why my code stops running after the first question. It will ask the user the first question, allow user input then say that the operation is complete. What am I doing wrong? Thanks.

import java.util.Scanner; public class TemperatureConverter {

public static void main(String[] args) {

   //Create scanner object
      Scanner keyboard = new Scanner(System.in);

   //Declare variables
      double temperature;
      double temp;
      String temperatureScale;

   //Use scanner to ask for user input
      System.out.println("What is the temperature?");
      temperature = keyboard.nextDouble();

   //Use scanner to ask for user input
      System.out.println("Is the temperature Celsius or Fahrenheit?");
      temperatureScale = keyboard.nextLine();

   //If statement 
      if (temperatureScale == "Fahrenheit"){
         temp = temperature - 32 * 5/9;
         System.out.println("The result is " + temp + "degrees Celsius.");
         }

      else if (temperatureScale == "Celsius"){
         temp = temperature * 1.8 + 32.0;
         System.out.println("The result is " + temp + "degrees 
         Fahrenheit.");
         }

      else{ 
         System.out.println("An incorrect value was input.");
         }     
 }
} 
Berry.Bee
  • 1
  • 2

1 Answers1

0

What you would expect? You have no loops in your app. Use while, for, do..while loops

Antoniossss
  • 31,590
  • 6
  • 57
  • 99