-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDay12_prob1.java
More file actions
77 lines (61 loc) · 1.97 KB
/
Day12_prob1.java
File metadata and controls
77 lines (61 loc) · 1.97 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
Sameer wants to develop a program for ATM. Help him by constructing the program for the same. In the program if user withdraws amount upto 1000 then machine will dispence Rs. 100 notes only. Minimum number of notes should be dispenced by the machine. Notes of denomination of 100,200,500 and 2000 are available in machine.
Input Format
One integer value between 100-20000.
Constraints
Maximum withdrawl amount should be 20000, Minimum should be 100 and amount should be in the multiple of 100 only.
Output Format
Print the number of notes dispenced and their denomination.
Sample Input 0
1100
Sample Output 0
1 100 Notes
2 500 Notes
Sample Input 1
1550
Sample Output 1
Invalid Input
*/
// kirtan jain
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if(n<100 || n>20000 || n%100!=0){
System.out.print("Invalid Input");
}
else{
int m100=0,m200=0,m500=0,m2000=0;
while(n!=0){
if(n>=2000){
m2000++;
n-=2000;
}
else if(n>=500){
m500++;
n-=500;
}
else if(n>=200){
m200++;
n-=200;
}
else{
m100++;
n-=100;
}
}
if(m100!=0){
System.out.println(m100+" 100 Notes");
}if(m200!=0){
System.out.println(m200+" 200 Notes");
}if(m500!=0){
System.out.println(m500+" 500 Notes");
}if(m2000!=0){
System.out.println(m2000+" 2000 Notes");
}
}
}
}