Guest User

5. Angle Unit Converter (Degrees ↔ Radians)

a guest
May 21st, 2014
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class _05_AngleUnitConverter {
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner sc = new Scanner(System.in);
  8.         int numberOfQueries = sc.nextInt();
  9.        
  10.         for (int i = 0; i < numberOfQueries; i++) {
  11.             double value = sc.nextDouble();
  12.             String measure = sc.next();
  13.             switch (measure) {
  14.             case "deg":
  15.                 System.out.printf("%6f rad\r\n", value * Math.PI / 180);
  16.                 break;
  17.             case "rad":
  18.                 System.out.printf("%6f deg\r\n", value * 180 / Math.PI);
  19.                 break;
  20.             default:
  21.                 break;
  22.             }
  23.         }
  24.  
  25.     }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment