Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class converter
- {
- public static void main(String[] args) throws java.io.IOException
- {
- char choice, ignore;
- double temp;
- Scanner input = new Scanner(System.in);
- do{System.out.println(" Выберите перевод\n " +
- "1. Из цельсия в фаренгейты\n " +
- "2. Из фаренгейта в цельсий");
- choice = (char) System.in.read();
- do{
- ignore = (char) System.in.read();
- } while (ignore != '\n');
- } while (choice < '1' | choice > '2');
- switch (choice){
- case '1':
- System.out.println("Введите данные: ");
- temp = input.nextDouble();
- System.out.println((temp * 1.8) + 32 );
- break;
- case '2':
- System.out.println("Введите данные: ");
- temp = input.nextDouble();
- System.out.println( (temp - 32) / 1.8 );
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment