Advertisement
Guest User

21312dasfsdf

a guest
Sep 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. public static void main ( String[]args) {
  2. double input=0,answer=0 ;
  3. int option = 0;
  4. input = inputMethod(input);
  5. //System.out.println(input);
  6. option= optionMethod(option);
  7. printAnswer(input,answer,option);
  8. //Scanner sc = new Scanner (System.in);
  9. }
  10.  
  11. public static double inputMethod(double input) {
  12. Scanner sc = new Scanner (System.in);
  13. System.out.print("Welcome.\n Please enter the Amount in CAD:");
  14. input = sc.nextFloat();
  15. //sc.close();
  16. return input;
  17. }
  18.  
  19.  
  20. public static int optionMethod(int option) {
  21. Scanner sc = new Scanner (System.in);
  22. System.out.println("\nSelect one of the following currencies to convert the amount into. or 1-USD or 2-Euro or 3-Rupee");
  23. option = sc.nextInt();
  24. while (option !=1 && option !=2 && option !=3) {
  25. System.out.println("\nInvalid input ! Enter Aagain !!");
  26. System.out.println("\nSelect one of the following currencies to convert the amount into. \n1USD \n2Euro \3Rupee");
  27. option = sc.nextInt();
  28. }
  29. sc.close();
  30. return option;
  31. }
  32.  
  33. public static int printAnswer (double input, double answer ,int option) {
  34. switch (option) {
  35. case 1:
  36. answer = input*0.76;
  37. System.out.println("\nThe conversion of CAD $"+input+" to USD is $"+answer);
  38. break;
  39. case 2:
  40. answer =input*0.68;
  41. System.out.println("\nThe conversion of CAD $"+input+" to USD is $"+answer);
  42. break;
  43. case 3:
  44. answer = input*53.73;
  45. System.out.println("\nThe conversion of CAD $"+input+" to USD is $"+answer);
  46. break;
  47. }
  48.  
  49. return (int)answer;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement