Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TempConverter2{
- public static void main(String[] args) {
- Double f;
- Double c;
- String type;
- Scanner kb = new Scanner(System.in);
- System.out.println("This program converts temperature.");
- System.out.println("Do you want to convert from Farenheit or Celcius?");
- type = kb.nextLine();
- if(type=="Farenheit"){
- System.out.println("What temperature is it?");
- f = kb.nextDouble();
- c = (f-32)/1.8;
- System.out.println("The temperature is " + c + " degrees Celcius.");
- }
- if(type=="Celcius") {
- System.out.println("What temperature is it?");
- c = kb.nextDouble();
- f = (c*1.8) + 32;
- System.out.println("The temperature is " + f + " degrees Farenheit.");
- }
- else{
- System.out.println("Did you spell something wrong? Try Celcius or Farenheit");
- }
- }
- }
Add Comment
Please, Sign In to add comment