Guest User

Untitled

a guest
May 27th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import java.util.*;
  2. class CurrencyConversion
  3. {
  4. public static void main(String args[])
  5. {
  6. /*Initalizing the required variables*/
  7. float rup,dol,ans;
  8. int ch=0;
  9.  
  10.  
  11. Scanner sc=new Scanner(System.in); //Scanner object to get input from user
  12. while(ch!=3) //while loop to run the program in repeating mode
  13. {
  14. System.out.print("\n1. Convert rupees to dollar. \n2. Convert dollar to rupees.\n3. Exit");
  15. System.out.print("\nEnter your choice: ");
  16. ch=sc.nextInt();
  17. switch(ch)
  18. {
  19. case 1: //Case 1 to conver rupees into dollar
  20. System.out.print("Enter the amount in rupees: ");
  21. rup=sc.nextFloat();
  22. ans=rup/60;
  23. System.out.print("Amount in dollar: "+ans+"\n");
  24. break;
  25.  
  26. case 2: //Case 2 to convert dollar into rupees
  27. System.out.print("Enter the amount in dollar: ");
  28. dol=sc.nextFloat();
  29. ans=dol*60;
  30. System.out.print("Amount in rupees: "+ans+"\n");
  31. break;
  32.  
  33. case 3: //Case 3 to exit from the program
  34. break;
  35.  
  36. default:
  37. System.out.print("Enter the correct choice...."+"\n");
  38. }
  39. }
  40. }
  41. }
Add Comment
Please, Sign In to add comment