Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main ( String[]args) {
- double input=0,answer=0 ;
- int option = 0;
- input = inputMethod(input);
- //System.out.println(input);
- option= optionMethod(option);
- printAnswer(input,answer,option);
- //Scanner sc = new Scanner (System.in);
- }
- public static double inputMethod(double input) {
- Scanner sc = new Scanner (System.in);
- System.out.print("Welcome.\n Please enter the Amount in CAD:");
- input = sc.nextFloat();
- //sc.close();
- return input;
- }
- public static int optionMethod(int option) {
- Scanner sc = new Scanner (System.in);
- System.out.println("\nSelect one of the following currencies to convert the amount into. or 1-USD or 2-Euro or 3-Rupee");
- option = sc.nextInt();
- while (option !=1 && option !=2 && option !=3) {
- System.out.println("\nInvalid input ! Enter Aagain !!");
- System.out.println("\nSelect one of the following currencies to convert the amount into. \n1USD \n2Euro \3Rupee");
- option = sc.nextInt();
- }
- sc.close();
- return option;
- }
- public static int printAnswer (double input, double answer ,int option) {
- switch (option) {
- case 1:
- answer = input*0.76;
- System.out.println("\nThe conversion of CAD $"+input+" to USD is $"+answer);
- break;
- case 2:
- answer =input*0.68;
- System.out.println("\nThe conversion of CAD $"+input+" to USD is $"+answer);
- break;
- case 3:
- answer = input*53.73;
- System.out.println("\nThe conversion of CAD $"+input+" to USD is $"+answer);
- break;
- }
- return (int)answer;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement