Computer Science, asked by kundaneur6132, 10 months ago

You went on a tour to Ooty with your friends. As a part of the tour, you went boating with them. For the boat to remain stable, the number of people on one boat is restricted based on the weight of the people. You find that the boatman who is sailing your boat is so much greedy of money. For earning more, he takes too many people to travel in the boat at a time. So you want to check how many people can travel in the boat at a time so that the boat will not drown. Calculate the weight by considering the number of adults and number of children. Assume that an adult weighs 75 kg and children weigh 30 kg each. If the weight is normal, display Boat is stable, else display Boat will drown. INPUT & OUTPUT FORMAT: Input consists of 3 integers. First input corresponds to the weight that the boat can handle. Second input corresponds to the number of adults. Third input corresponds to the number of children. SAMPLE INPUT: 340 2 3 SAMPLE OUTPUT: Boat is stable

Answers

Answered by TheArkhamKnight
0

Answer:

def boatIsStable(weight, children, adults):

  children = children*30

  adults = adults*75

  totalMassOnBoard = children+adults

  if totalMassOnBoard > weight:

           print("Boat is unstable")

   else:

            print("Boat is stable")

Explanation:

This explanation is done in python. (I hope that's OK). So, we are making a function to calculate whether the boat is stable. This function has three parameters: the weight that the boat can handle, the amount of children, and the amount of adults (in that order). First of all, we make the children equal to the amount of children multiplied by their weight (30). Then we do the same for the adults. We then make a variable called totalMassOnBoard, which is equal to the value of children plus the value of adults. then we do an if statement: if the total mass on board variable is bigger than the weight parameter then we say the boat is unstable. In any other cases (they are the same, or the total mass on board is less than the boat's maximum weight), we say the boat is stable.

Similar questions