Lab 6 7
Lab 6 7
3. Areas of Rectangles
The area of a rectangle is the rectangle’s length times its width. Write a program that asks for the length
and width of two rectangles. The program should tell the user which rectangle has the greater area, or if
the areas are the same.
4. Age Classifier
Write a program that asks the user to enter a person’s age. The program should display a message
indicating whether the person is an infant, a child, a teenager, or an adult.
Following are the guidelines:
• If the person is 1 year old or less, he or she is an infant.
• If the person is older than 1 year, but younger than 13 years, he or she is a child.
• If the person is at least 13 years old, but less than 20 years old, he or she is a
teenager.
• If the person is at least 20 years old, he or she is an adult.
5. Roman Numerals
Write a program that prompts the user to enter a number within the range of 1
through 10. The program should display the Roman numeral version of that
number. If the number is outside the range of 1 through 10, the program should
display an error message.
6. Color Mixer
The colors red, blue, and yellow are known as the primary colors because they cannot be made by mixing
other colors. When you mix two primary colors, you get a secondary color, as shown here:
When you mix red and blue, you get purple.
When you mix red and yellow, you get orange.
When you mix blue and yellow, you get green.
Design a program that prompts the user to enter the names of two primary colors to mix. If the user enters
anything other than “red,” “blue,” or “yellow,” the program should display an error message. Otherwise,
the program should display the name of the secondary color that results.
Assume hot dogs come in packages of 10, and hot dog buns come in packages of 8. Write a program that
calculates the number of packages of hot dogs and the number of packages of hot dog buns needed for a
cookout, with the minimum amount of leftovers. The program should ask the user for the number of
people attending the cookout and the number of hot dogs each person will be given. The program should
display the following details:
• The minimum number of packages of hot dogs required
• The minimum number of packages of hot dog buns required
• The number of hot dogs that will be left over
• The number of hot dog buns that will be left over
Write a program that asks the user to enter a pocket number and displays whether the pocket is green, red,
or black. The program should display an error message if the user enters a number that is outside the
range of 0 through 36.
Create a change-counting game that gets the user to enter the number of coins required to make exactly
one dollar. The program should prompt the user to enter the number of pennies, nickels, dimes, and
quarters. If the total value of the coins entered is equal to one dollar, the program should congratulate the
user for winning the game. Otherwise, the program should display a message indicating whether the
amount entered was more than or less than one dollar.
10.Book Club Points
Serendipity Booksellers has a book club that awards points to its customers based on the number of books
purchased each month. The points are awarded as follows:
Write a program that asks the user to enter the number of books that he or she has purchased this month,
then displays the number of points awarded.
The Fast Freight Shipping Company charges the following rates: Weight of Package Rate per Pound
2 pounds or less $1.50
Over 2 pounds but not more than 6 pounds $3.00
Over 6 pounds but not more than 10 pounds $4.00
Over 10 pounds $4.75
Write a program that asks the user to enter the weight of a package then displays the shipping charges.
You have a group of friends coming to visit for your high school reunion, and you want
14. Restaurant Selector
To take them out to eat at a local restaurant. You aren’t sure if any of them have dietary
restrictions, but your restaurant choices are as follows:
Write a program that asks whether any members of your party are vegetarian, vegan, or
gluten-free, to which then displays only the restaurants to which you may take the group.
Here is an example of the program’s output:
Corner Cafe
The Chef's Kitchen