Write a multi-way if-else statement that evaluates a persons weight on the follo
ID: 673592 • Letter: W
Question
Write a multi-way if-else statement that evaluates a persons weight on the following criteria: A weight less than 115 pounds, output: Eat 5 banana splits! A weight between 116 pounds and 130 pounds, output: Eat a banana split! A weight between 131 pounds and 200 pounds, output: Perfect! A weight greater than 200 pounds, output: Plenty of banana splits have been consumed! Write an if-else statement to compute the amount of shipping due on an online sale. If the cost of the purchase is less than $20, the shipping cost is %5.99. If the cost of the purchase over $20 and at most $65, the shipping cost is $10.99. If the cost of the purchase is over $65, the shipping cost is $15.99.Explanation / Answer
Solution-1 :
if(weight < 115)
print("Eat 5 banana splits");
else if(weight >= 116 && weight <= 130)
print("Eat 1 banana splits");
else if(weight >= 131 && weight <= 200)
print("Perfect");
else if(weight >200)
print("Plenty of Banana's Consumed");
Solution-2:
let COP- cost of purchase, SC-Shipping Cost
if(COP<20)
SC=5.99;//(in $)
else if(COP>=20 && COP <=65)
SC=10.99;//(in $)
else if(COP>65)
SC=15.99;//(in $)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.