Guest User

Untitled

a guest
Sep 9th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. public class converter
  2.  
  3. {
  4.     public static void main(String[] args)   throws java.io.IOException
  5.     {
  6.         char choice, ignore;
  7.         double temp;
  8.         Scanner input = new Scanner(System.in);
  9.         do{System.out.println(" Выберите перевод\n " +
  10.                 "1. Из цельсия в фаренгейты\n " +
  11.                 "2. Из фаренгейта в цельсий");
  12.             choice = (char) System.in.read();
  13.             do{
  14.                 ignore = (char) System.in.read();
  15.             } while (ignore != '\n');
  16.         } while (choice < '1' | choice > '2');
  17.  
  18.         switch (choice){
  19.             case '1':
  20.                 System.out.println("Введите данные: ");
  21.                 temp = input.nextDouble();
  22.                 System.out.println((temp * 1.8) + 32 );
  23.                 break;
  24.  
  25.             case '2':
  26.                 System.out.println("Введите данные: ");
  27.                 temp = input.nextDouble();
  28.                 System.out.println( (temp - 32) / 1.8 );
  29.                 break;
  30.         }
  31.  
  32.  
  33.     }
  34.  
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment