-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
44 lines (40 loc) · 1018 Bytes
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter amount: ");
int amount = input.nextInt();
int quarter = 0;
int dime = 0;
int nickel = 0;
int penny = 0;
int total = quarter + dime + nickel + penny;
while (amount > 0){
if(amount >= 25){
quarter += 1;
total++;
amount = amount - 25;
}
else if (amount >= 10){
dime += 1;
total++;
amount = amount - 10;
}
/*else if(amount >= 5){
nickel += 1;
total++;
amount = amount - 5;
}*/
else {
penny += 1;
total++;
amount = amount - 1;
}
}
System.out.println("Quarters: " + quarter);
System.out.println("Dimes: " + dime);
System.out.println("Nickels: " + nickel);
System.out.println("Pennies: " + penny);
System.out.println("Total amount of coins: " + total);
}
}