Advertisement
Guest User

Untitled

a guest
May 19th, 2014
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 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.        
  8.         Scanner sc = new Scanner(System.in);
  9.        
  10.         int rows = sc.nextInt();
  11.        
  12.         double[] number = new double[rows];
  13.         String[] type = new String[rows];
  14.        
  15.         for (int i = 0; i < rows; i++) {
  16.             number[i] = sc.nextDouble();
  17.             type[i] = sc.next();
  18.         }
  19.        
  20.         for (int i = 0; i < rows; i++) {
  21.             convert(number[i], type[i]);
  22.         }
  23.     }
  24.    
  25.     public static void convert(double number, String type){
  26.        
  27.         double result = 0;
  28.        
  29.         if(type.equals("deg")){
  30.             result = Math.toRadians(number);
  31.             System.out.printf("%.6f rad \n", result);
  32.         }
  33.         else if(type.equals("rad")){
  34.             result = Math.toDegrees(number);
  35.             System.out.printf("%.6f deg \n", result);
  36.         }
  37.     }
  38.    
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement