There is a Bucket of water capacity of thes, which is
supposed to fill with a mug ofy mitres water
capacity. Say for example 100 and y=10 then,
bucket will get full of minimum of 8 mugs > 80% and
less than 100%
Bucket filling is to be stopped once more than 80% of
bucket capacity is filled.
The amount of water taken at a time in mug is not
fixed as it can be any value less than or equal to y.
Notify to stop once bucket is full that is more than
80% of capacity of bucket and count number of mugs
poured into bucket.
Note that Bucket capacity will always be greater that
Mug's Capacity.
Example 1:
INPUT VALUES
100
// Enter Bucket capacity in litres as this
20
1/ Enter Mug capacity in litres as this
//Enter Amount of water in MUG one after other as
below
20
20
20
Answers
Answer:
very long mate
Explanation:
import java.util.Scanner;
public class Bucket {
public static void check(int a,int b){
int count=0,fill=0;double cal=0;int flag=0;
cal = a*0.8;
if(b>a){
flag=1;
}
else{
System.out.println("Enter your amount of water in mugs");
while(fill<cal){
Scanner sc = new Scanner(System.in);
int mugs = sc.nextInt();
if(mugs>b || mugs<0){
flag=1;
break;
}
else{
fill+=mugs;
count+=1;
}
}
}
if(flag==0){
System.out.println("Number of mugs to fill a bucket :"+count);
}
else{
System.out.println("Invalid input");
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a Bucket Size in Lit and Size of Mug");
int bsx =sc.nextInt();
int msx = sc.nextInt();
check(bsx,msx);
}
}