-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoinProb.java
More file actions
32 lines (26 loc) · 753 Bytes
/
CoinProb.java
File metadata and controls
32 lines (26 loc) · 753 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
package hello;
// Amount is 13 then total coins are 6 and 132
import java.util.Scanner;
public class CoinProb {
public static void main(String[] args) {
Scanner sc=new Scanner (System.in);
System.out.println(" Enter No"); //13
int num=sc.nextInt();
int one=0; //0
int two=0; //0
int five=(num-4)/5; //1 five=1
if((num-5*five)%2==0) //(13-5)%2==0 //8%2==0
{ // |
one=2; // <-------------------- one=2
}
else
{
two=1;
}
two =(num-5*five-one)/2; // (13-5*1-2)/2 //6/2 // two =3
System.out.println(one+two+five);
System.out.println(five);
System.out.println(two);
System.out.println(one);
}
}