My assignment requires me to read a number entered by the user and output the coins that number makes. For example, if the user enters "37", the program should respond with (1 Quarter, 1 dime, and 2 pennies).
This is the code I've gotten so far I would appreciate it if someone could help me finish it as well as see if my current code has any errors
import java.util.Scanner;
public class Coin
{
Scanner sc = new Scanner (System.in);
Int n = sc.nextInt("Enter a positive integer" );
int number1, number2; // Division operands
int quotient; // Result of division
public static int getQuarters(int cents) {
return Math.floor(cents / 25.0);
}
public static int getDimes(int cents) {
return Math.floor(cents / 10.0);
}
public static int getNickels(int cents) {
return Math.floor(cents / 5.0);
}
public static int getPennies(int cents) {
return Math.floor(cents / 1.0);
}
public static void main(String[] args) {
int cents = 46;
int left = cents;
int quarters = getQuarters(cents);
int left -= quarters * 25;
int dimes = getDimes(left);
left -= dimes * 10;
int nickels = getNickels(left);
left -= nickels * 5;
int pennies = left;
System.out.println(cents + " cents = " + quarters + " Quarters, " + dimes + " Dimes, " + nickels + " Nickels, and " + pennies + " Pennies."); // print the output
}
}