Guest User

Untitled

a guest
Sep 9th, 2015
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 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.         do{System.out.println(" Выберите перевод\n " +
  9.                 "1. Из цельсия в фаренгейты\n " +
  10.                 "2. Из фаренгейта в цельсий");
  11.             choice = (char) System.in.read();
  12.             do{
  13.                 ignore = (char) System.in.read();
  14.             } while (ignore != '\n');
  15.         } while (choice < '1' | choice > '2');
  16.  
  17.         switch (choice){
  18.             case '1':
  19.                 System.out.println("Введите данные: ");
  20.                  temp = (double) System.in.read();
  21.                 System.out.println((temp * 1.8) + 32 );
  22.                 break;
  23.  
  24.             case '2':
  25.                 System.out.println("Введите данные: ");
  26.                 temp = (double) System.in.read();
  27.                 System.out.println( (temp - 32) / 1.8 );
  28.                 break;
  29.         }
  30.  
  31.  
  32.     }
  33.  
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment