The attached image is the question and what I must accomplish.
This is what I have so far:
public class ChangeCalc{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int change = 0;
int quarters = 25;
int dimes = 10;
int nickels = 5;
System.out.println("How much change (in cents)?: ");
change = sc.nextInt();
int result1 = 0;
int result2 = 0;
int result3 = 0;
if( change < 100 ) {
System.out.println("Quarters = " + Quarters( change, result1, quarters));
System.out.println("Dimes = " + Dimes( change, result1, result2, dimes));
System.out.println("Nickels = " + Nickels(change, result2, result3, nickels));
System.out.println("Pennies = " + ( change - (result1 + result2 + result3)));
}
}
public static int Quarters( int change, int result1, int quarters ) {
result1 = change - (change % quarters);
return result1;
}
public static int Dimes( int change, int result1, int result2, int dimes){
result2 = change - (result1 % dimes);
return result2;
}
public static int Nickels( int change,int result2, int result3, int nickels){
result3 = change - (result2 % nickels);
return result3;
}
}```
Can anyone please tell me what I am doing wrong and what I should change or fix?