12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
-
- import java.util.Scanner;
-
-
- public class CurrencyConverter {
-
-
- public double convertCurrency(double currency1, double currency2, double amount) {
- double converted = (currency2 * amount)/ currency1; //converts to currency2
- return converted;
-
- }
-
- public double getStringInput(String prompt) {
-
-
- double userSelection = 0;
- while(userSelection == 0){
- Scanner scanner = new Scanner(System.in);
- System.out.println(prompt);
- String userInput = scanner.nextLine();
- switch(userInput){
- case "us dollar" : userSelection = 1.00;
- break;
- case "euro" : userSelection = 0.94;
- break;
- case "british pound" : userSelection = 0.82;
- break;
- case "indian rupee" : userSelection = 68.32;
- break;
- case "australian dollar" : userSelection = 1.35;
- break;
- case "canadian dollar" : userSelection = 1.32;
- break;
- case "singapore dollar" : userSelection = 1.43;
- break;
- case "swiss franc" : userSelection = 1.01;
- break;
- case "malaysian ringgit" : userSelection = 4.47;
- break;
- case "japanese yen" : userSelection = 115.84;
- break;
- case "chinese yuan renminbi" : userSelection = 6.92;
- break;
- default : System.out.println("That money ain't nothin' to #$%& with");
- System.out.println("Choose a some money we can work with!");
- break;
- }
- }
-
- return userSelection;
- }
-
- public double getDoubleInput(String prompt) {
- Scanner scannerB = new Scanner(System.in);
- double b = 0;
- System.out.println(prompt);
- while(b == 0){
- if(scannerB.hasNextDouble()){
- b = scannerB.nextDouble();
- }else{
- System.out.println("Invalid input please choose a number greater than 0\n");
- }
- }
- return b;
-
- }
-
- }
|