-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCash.java
More file actions
39 lines (36 loc) · 857 Bytes
/
Copy pathCash.java
File metadata and controls
39 lines (36 loc) · 857 Bytes
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
package android;
import java.util.Scanner;
public class Cash {
public static void main(String[]args) {
System.out.println("Enter the cash that cashier has to give");
float n;
int c=0,c1=0,c2=0,c3=0;
Scanner sc=new Scanner(System.in);
n=sc.nextFloat();
n=n*100;
while(n>0) {
if(n>=25&&(n-25)>=0 )
{
c=c+1;
n=n-25;
}
else if((n>=10&&n<25)&&(n-10)>=0) {
c1=c1+1;
n=n-10;
}
else if((n>=5&&n<10)&&(n-5)>=0) {
c2=c2+1;
n=n-5;
}
else if((n>=1&&n<5)&&(n-1)>=0) {
c3=c3+1;
n=n-1;
}
}
System.out.println("The number of quaters given is"+c);
System.out.println("The number of dimes given is"+c1);
System.out.println("The number of nickels given is"+c2);
System.out.println("The number of pennies given is"+c3);
sc.close();
}
}