Question
1) yyyy lab4-1 where yyyy is your last name: Suppose you shop for rice and find it in two different-sized packages.You would like to write
1) yyyylab4-1where yyyyis your last name:
Suppose you shop for rice and find it in two different-sized packages.You would like to write a program to compare the costs of the packages.The program prompts the user to enter the weight and price of the package and then displays the one with the better price. (You do not need to know/use the units of measure of the weight.)
Here is a sample run (which follows the explanation to the user of what it does.):
Enter the weight and price for package 1 (with a comma between them):50, 24.59
Enter the weight and price for package 2:25, 11.99
Package 2 has the better price.
2) yyyylab4-2where yyyyis your last name:
write a program that lets the user guess whether a flipped coin displays heads or tails.The program randomly generates an integer ( 0 or 1 ), which represents head or tail.The program prompts the user to enter a guess and reports whether the guess is correct or incorrect
This program plays the game or heads or tails.Try to match the computer's choice.
Type 0 for heads or 1 for tails.0
Congratulations! Your guess is correct.
3) yyyylab4-3where yyyyis your last name:
write a program that reads three sides for a triangle and computes the perimeter if the input is valid.Otherwise, display that the input is invalid.The input is valid if the sum of every pair of two sides is greater than the remaining side.Here is a sample:
This program calculates the perimeter of a triangle. Enter the length of the three sides with a comma between them:1, 1, 1
The perimeter is 3.
This program calculates the perimeter of a triangle. Enter the length of the three sides with a comma between them:1, 3, 1
The input is invalid.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started