Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

IN C Programming Problem: Outfitting the Crew Now that your friend has a crew, they will need to outfit them with enough gear to get

IN C Programming

Problem: Outfitting the Crew Now that your friend has a crew, they will need to outfit them with enough gear to get them to the Caribbean and support them through obtaining treasure. In their home port, your friend can purchase new gear or used gear. New gear is more expensive, but will last longer. If you can find quality used gear, it will be more cost effective. Your program should prompt the user with the following menu: 1) Buy New Gear 2) Buy Used Gear 3) Quit If your friend would like to buy gear (either new or used), you should next ask how many pieces of gear they would like to buy. The price of gear is pre-determined using the following values: Used gear sells for 5 gold pieces. New gear sells for 15 gold pieces. Your program must keep track of the total amount that your friend will spend for their gear. This total should be printed out when your friend decides to quit buying gear. You should also print how many pieces of new gear they obtained, how many pieces of used gear they obtained, and the average cost per piece of gear for their crew. If your friend quits before buying anything; print that their final cost will be 0 gold pieces and that they bought 0 pieces of gear. Do not print an average in this case. If the user inputs an invalid menu choice, your program should tell them that their choice is invalid and present the menu again.

Input Specification 1. All input values will be integers.

Output Specification Output the results using the format below: Your total cost is X gold pieces. You obtained Y pieces of new gear and Z pieces of used gear. The average cost per piece of gear is A.AA pieces of gold.

Output Samples Below are some sample outputs of running the program. Note that these samples are NOT a comprehensive test. You should test your program with different data than is shown here based on the specifications given above. In the sample run below, for clarity and ease of reading, the user input is given in italics while the program output is in bold. (Note: When you actually run your program no bold or italics should appear at all. These are simply used in this description for claritys sake.)

Sample Run #1 New Gear Welcome to the market! What would you like to do? 1. Buy New Gear. 2. Buy Used Gear. 3. Quit 1 How many pieces of new gear would you like to buy? 3 What would you like to do? 1. Buy New Gear. 2. Buy Used Gear. 3. Quit 3 Your total cost is 45 gold pieces. You obtained 3 pieces of new gear and 0 pieces of used gear. The cost per piece of gear is 15.00 pieces of gold.

Sample Run #2 Used Gear Welcome to the market! What would you like to do? 1. Buy New Gear. 2. Buy Used Gear. 3. Quit 2 How many pieces of used gear would you like to buy? 3 What would you like to do? 3 1. Buy New Gear. 2. Buy Used Gear. 3. Quit 3 Your total cost is 15 gold pieces. You obtained 0 pieces of new gear and 3 pieces of used gear. The cost per piece of gear is 5.00 pieces of gold.

Sample Run #3 Unusual Cases Welcome to the market! What would you like to do? 1. Buy New Gear. 2. Buy Used Gear. 3. Quit 5 Sorry, 5 is not a valid choice. What would you like to do? 1. Buy New Gear. 2. Buy Used Gear. 3. Quit 3 Your total cost is 0 gold pieces. You obtained 0 pieces of new gear and 0 pieces of used gear.

Sample Run #4 Both New and Used Welcome to the market! What would you like to do? 1. Buy New Gear. 2. Buy Used Gear. 3. Quit 1 How many pieces of new gear would you like to buy? 3 What would you like to do? 1. Buy New Gear. 2. Buy Used Gear. 3. Quit 2 How many pieces of used gear would you like to buy? 5 What would you like to do? 4 1. Buy New Gear. 2. Buy Used Gear. 3. Quit 3 Your total cost is 70 gold pieces. You obtained 3 pieces of new gear and 5 pieces of used gear. The cost per piece of gear is 8.75 pieces of gold.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students explore these related Databases questions

Question

Discuss the different types of leadership

Answered: 3 weeks ago

Question

Write a note on Organisation manuals

Answered: 3 weeks ago