English, asked by shindekomal929, 5 months ago

Language program.There is a Bucket of water capacity of x litres, which is supposed to fill with a mug of y millilitres water capacity. Say for example x=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 this 20 // Enter Bucket capacity in litres as // Enter Mug capacity in litres as this 2 // enter amount of water in MUG one after other as below 20 20 20 20 20 .output values bucket full!no.of mugs:4 .write a problem on c,c++,java

Answers

Answered by Anonymous
4

Answer:

good morning have a nice and blessed day

Answered by dreamrob
0

Program in C++

#include<iostream>

using namespace std;

int main()

{

double b , m;

cout<<"Enter bucket capacity in liters(L) : ";

cin>>b;

cout<<"Enter mug capacity in mililiters(mL)): ";

cin>>m;

b = b * 1000;

if(b > m && m != 0 && b != 0)

{

 double full_b = b * 0.8;

 double full = 0.0;

 int count_mug = 0;

 while(full < full_b)

 {

  double water;

  cout<<"Enter amount of water in the mug : ";

  cin>>water;

  if(water <= m && water != 0)

  {

   full = full + water;

   count_mug++;

  }

  else("Invalid Input");

 }

 cout<<"Bucket Full"<<endl;

 cout<<"Number of mugs poured = "<<count_mug;

}

else

{

 cout<<"Invalid Input";

}

return 0;

}

Output 1:

Enter bucket capacity in liters(L) : 1

Enter mug capacity in mililiters(mL)): 200

Enter amount of water in the mug : 100

Enter amount of water in the mug : 100

Enter amount of water in the mug : 100

Enter amount of water in the mug : 50

Enter amount of water in the mug : 50

Enter amount of water in the mug : 100

Enter amount of water in the mug : 50

Enter amount of water in the mug : 100

Enter amount of water in the mug : 100

Enter amount of water in the mug : 100

Bucket Full

Number of mugs poured = 10

Output 2:

Enter bucket capacity in liters(L) : 0.1

Enter mug capacity in mililiters(mL)): 20

Enter amount of water in the mug : 20

Enter amount of water in the mug : 20

Enter amount of water in the mug : 20

Enter amount of water in the mug : 20

Bucket Full

Number of mugs poured = 4

Similar questions