-
-
Save timsegraves/3646311 to your computer and use it in GitHub Desktop.
Austin's Convert Program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Convert | |
{ | |
public static void main(String[] args) | |
{ | |
//allowing us to take input from the keyboard | |
Scanner keyboard = new Scanner(System.in); | |
//delcaring variables | |
double dollar; | |
int country; | |
final double england_1 = .63; | |
final double japan_2 = 78.5; | |
final double china_3 = 6.36; | |
double convert = 0.0; | |
string currencyName = ""; | |
bool errorConverting = false; | |
//asking the user for dollar amount and country | |
System.out.println("Enter the US dollar ammount:"); | |
dollar = keyboard.nextDouble(); | |
System.out.println("Choose one of the following countries\n1. England\n2. Japan\n3. China"); | |
country = keyboard.nextInt(); | |
switch (country) { | |
case 1: convert = dollar * england_1; | |
currencyName = "pounds"; | |
case 2: convert = dollar * japan_2; | |
currencyName = "yen"; | |
case 3: convert = dollar * china_3; | |
currencyName = "RMB"; | |
default: convert = 0; | |
currencyName = "Error Converting Currency"; | |
errorConverting = true; | |
} | |
if (errorConverting) { | |
System.out.println(currencyName); | |
} | |
else { | |
System.out.println(dollar + " dollars is equal to " + convert + " " + currencyName); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment