Im totally new to java and my first task is to make a currency calculator from US dollar to NOK(Norsk Kroner). And the program should calculate and show how this amount most effectively can be cashed out i all norwegian paying units. I Have been trying all day, but getting nowhere. Anybody who can help me out with my code?
Heres my code:
/*
* Valutacalc
*
*/
import static java.lang.System.*;
import static java.lang.Integer.*;
import static javax.swing.JOptionPane.*;
public class Kalkulator {
public static void main(String[] args) {
// Leser verdi fra brukeren
String tallTxt = showInputDialog("Antall US Dollar");
int dollar = parseInt(tallTxt);
double valuta = 5,49;
// Beregner svarene av regnearbeidet /
int svar1 = dollar * valuta;
//Skriv ut resultat
showMessageDialog(null, dollar * " * " valuta " = " + svar1 + "\n");
}
}
replace
by
Because decimal point in java is ‘.’ not ‘,’.
May be you also want to change type of
svar1todoublealso change:
to
The hole code: