Okay so I am required to enter an decimal amount such as "7.53" via JOptionPane and echo that by System.out.println
I have the start of the code here, but It gives me an error when i enter (7.53) as my input.. how can i input it in decimal form?
import javax.swing.*;
public class A1Q1 {
public static void main (String [] args) {
//Declaring Variables Here
String userInput;
double amount;
double amount2;
double toonies = 2.00;
double loonies = 1.00;
double quarters = 0.25;
double dimes = 0.10;
double nickles = 0.05;
double pennies = 0.01;
int mydoub;
//Accepting User Input
userInput = JOptionPane.showInputDialog(null,"Please enter an amount");
amount = Integer.parseInt(userInput);
}
}
THIS IS MY INTERACTION PANE
java.lang.NumberFormatException: For input string: "7.53"
at java.lang.NumberFormatException.forInputString(Num berFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:458)
at java.lang.Integer.parseInt(Integer.java:499)
at WahidMuhammadA1Q1.main(WahidMuhammadA1Q1.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at edu.rice.cs.drjava.model.compiler.JavacCompiler.ru nCommand(JavacCompiler.java:272)
>