Okay so I am supposed to write a code which accepts a certain amount of money ( 7.53) which then outputs what coins i need to make this amount up, i try it and compile it, but its giving me the interactions shown below as decimals and not whole numbers. (obvs it doesnt look good to have 0.003765 toonies) Please HELP THANKS
import java.util.*;
import javax.swing.*;
public class CoinCounter {
public static void main (String [] args){
Scanner sc = new Scanner(System.in);
String userInput;
double amount;
int loonie;
int toonie;
int quarter;
int dime;
int nickle;
int pennie;
int totalCoins = 0;
double myCoins;
userInput = JOptionPane.showInputDialog("Please enter an amount");
amount = Double.parseDouble(userInput);
System.out.println("Enter the amount");
amount=sc.nextDouble();
System.out.println((amount / 200) + " – toonies");
myCoins = (amount / 200);
amount = amount % 200;
if(amount > 0){
for(int a = 0; a < myCoins; a++ ){
totalCoins++;
}
}
System.out.println((amount / 100) + " – loonies");
myCoins = (amount / 100);
amount = amount % 100;
if(amount > 0){
for(int a = 0; a < myCoins; a++ ){
totalCoins++;
}
}
System.out.println((amount / 25) + " – quarters");
myCoins = (amount / 25);
amount = amount % 25;
if(amount > 0){
for(int a = 0; a < myCoins; a++ ){
totalCoins++;
}
}
System.out.println((amount / 10) + " – dimes");
myCoins = (amount / 10);
amount = amount % 10;
if(amount > 0){
for(int a = 0; a < myCoins; a++ ){
totalCoins++;
}
}
System.out.println((amount / 5) + " –Nickles");
myCoins = (amount / 5);
amount = amount % 5;
if(amount > 0){
for(int a = 0; a < myCoins; a++ ){
totalCoins++;
}
}
System.out.println((amount/1) + " – pennies");
myCoins = (amount);
amount = amount % ;
if(amount > 0){
for(int a = 0; a < myCoins; a++ ){
totalCoins++;
}
}
System.out.println("Total Coins: " + totalCoins);
}
}