I'm trying to make a USD <-> JPY converter. If the numbers seem off to you, trust me - I did the math. Also, I know the spacing's off, but it doesn't matter. Morph it in N++ if you need to.
import java.util.Scanner;
import java.lang.Math;
public class jpy_usd {
public static void main(String[] args) {
//Initializing variables and the scanner
boolean isSourceUSD;
double usd;
double usdMult = 0.00803568;
int jpy;
double jpyMult = 124.449;
Scanner scanner = new Scanner(System.in);
//Selecting an input currency and checking for valid input arguments
System.out.println("Choose your input currency. Type \'USD\' for U.S. Dollars or \'JPY\' for Japanese Yen.");
while(isSourceUSD != true && isSourceUSD != false) {
if(scanner.nextLine == "USD") {
isSourceUSD = true;
} else if(scanner.nextLine == "JPY") {
isSourceUSD = false;
} else {
System.out.println("Invalid argument. Please use \'USD\' for U.S. Dollars or \'JPY\' for Japanese Yen.");
}
}
//Asking for the input in the chosen currency and converting
if(isSourceUSD) {
System.out.println("Please enter the value to convert");
usd = scanner.nextDouble;
System.out.println(usd " in JPY is " (Math.round(usd * jpyMult)));
} else if(!isSourceUSD) {
System.out.println("Please enter the value to convert");
jpy = scanner.nextInt;
System.out.println(jpy " in USD is " (Math.round(jpy * usdMult)));
}
}
}
If you want me to add the error messages, I suppose I could. Without much explanation, there's 6 errors split evenly across these two lines:
System.out.println(usd " in JPY is " (Math.round(usd * jpyMult)));
System.out.println(jpy " in USD is " (Math.round(jpy * usdMult)));
There's two of each error - one per line - so the similarities in the lines have to be the same issues (duh). So, anybody got any clues?
P.S.: If there's anyhing wrong with the code other than that, please do mention it.
P.S. 2: I know I'm basically making this code public by putting every single character into this block of text, but please don't steal. I know someone's about to do it, but please don't. ~wundr