Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*In C Can I please get help with this code? Im having trouble getting started. thank you Write a program to simulate a simple self-serve

*In C
Can I please get help with this code? Im having trouble getting started. thank you image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Write a program to simulate a simple self-serve gas station with one gas pump that provides: Two grades of fuel: Regular and Diesel Accepts a discount card A car wash with two options A receipt Specifications 1. Use Functions 2. Use correct data types and constants where possible (see p.220 for example of constant) 3. To simulate the gas pump 3 things must occur: First provide a setup mode o This simulates the store setting the price for Regular and Diesel fuels . Second provide a customer mode o Infinite loop that waits for the next customer o When customer arrives, ask for the following: Discount card? (Y/N) . If customer has a discount card, reduce fuel cost by $0.03 per gallon & Car Wash? (Y/N) If customer wants a car wash then ask them what kind of car wash o Basic for $2.00 o Premium for $5.00 o Basic for $2.00 o Premium for $5.00 $ Credit card . We need to fake the process of scanning a credit card! Ask for zip code and assume customer swiped credit card $ Fuel grade? (Regular/Diesel) $ Receipt? (Y/N) 277 If customer wants a receipt, it must contain: o number of gallons o price per gallon o fuel cost o car wash cost and car wash code if selected car wash o total cost o Display fueling mode like a regular gas pump does $ Generate a random number to represent the number of gallons the customer pumps. See section 5.10 and 5.11 of your book to seed rand properly. $ Set the max number of gallons to 30. Pump the exact number of gallons that is returned from random function. Third, provide a way to shut down the pump and print a report Third, provide a way to shut down the pump and print a report o Essentially, we need a way to stop the infinite customer loop. We'll call this shutting down the gas pump. Perform these steps to accomplish pump shutdown: $ When prompting for a discount card, customers can enter values of 'Y' or 'N' $ To shut down the pump, the owner will enter a 'Q'. This is the backdoor. $ To verify it's the owner, ask for the shutdown pin. $ Use 2445 as the shutdown pin. After the 'Q' and correct pin are entered, exit the customer loop and create a report showing: Total number of gallons dispersed for all customers Total sales for all customers (fuel costs only, do not include car washes) 4. The code must handle user validation for the different user selections. When invalid input is entered, repeat same question until a valid value is entered. Check input on: Fuel prices NOTE you do not need to handle if numbers are not put in. This can be an optional extension. Discount card input Car wash input and type of car wash innut U 4. The code must handle user validation for the different user selections. When invalid input is entered, repeat same question until a valid value is entered. Check input on: - Fuel prices NOTE you do not need to handle if numbers are not put in. This can be an optional extension. Discount card input Car wash input and type of car wash input Fuel grade Receipt For the Y/N questions, handle uppercase and lower- case values. See output for examples. Output Your output may look similar to the following: Gas Station Pump 17 Setup Enter price of regular fuel: 2.49 Enter price of diesel fuel: 2.59 Are these the correct prices? y 377 Welcome to Gas Station 2060 B Output Your output may look similar to the following: Gas Station Pump 17 Setup Enter price of regular fuel: 2.49 Enter price of diesel fuel: 2.59 Are these the correct prices? y 3/7 Welcome to Gas Station 2060 Do you have a discount card? (Y/N) y Scanning your discount card... $0.03/Gallon Discount Car wash? (Y/N) y 1 Basic Wash $2.00 2 Premium Wash $5.00 Enter cash wash type: 2 Insert credit card Enter zip code 80919 Please Wait... Authorizing .... 2 Please Wait... Authorizing .... Lift nozzle and select grade - Regular (1) or Diesel (2): 1 ** $2.46 ** $4.92 ** $7.38 Fueling 1 Gallons ** 2 Gallons ** 3 Gallons ** ******* Receipt? (Y/N) Y Receipt Gallons: 3 Price/gallon: $2.46 Fuel cost: $7.38 Car wash cost: $5.00 (code: 1751) Total: $12.38 Thank You for Your Business! Welcome to Gas Station 2060 welcome to Gas Station ZOU Do you have a discount card? (Y/N) t Invalid input, do you have a discount card? (Y/N) y Scanning your discount card... $0.03/Gallon Discount Car wash? (Y/N) m Invalid input, car wash? (Y/N) 5 Invalid input, car wash? (Y/N) n Insert credit card Enter zip code 80919 Please Wait... Authorizing .... Lift nozzle and select grade - Regular (1) or Diesel (2): 0 Invalid input, select grade - Regular (1) or Diesel (2) 3 Invalid input, select grade - Regular (1) or Diesel (2) 2 *********** Fueling ** $2.56 1 Gallons ** ** $5.12 2 Gallons ** $7.68 3 Gallons ** $5.12 ** $7.68 ** $10.24 ** $12.80 ** $15.36 ** $17.92 ** $20.48 ** $23.04 ** $25.60 ** $28.16 ** $30.72 ** $33.28 ** $35.84 ** $38.40 ** $40.96 ** $43.52 ** $46.08 ** $48.64 ** $51.20 ** $53.76 ** $56.32 ** $58.88 2 Gallons 3 Gallons ** 4 Gallons ** 5 Gallons ** 6 Gallons ** 7 Gallons ** 8 Gallons 9 Gallons 10 Gallons ** 11 Gallons ** 12 Gallons ** 13 Gallons ** 14 Gallons ** 15 Gallons ** 16 Gallons ** 17 Gallons ** 18 Gallons ** 19 Gallons ** 20 Gallons ** 21 Gallons ** 22 Gallons ** 23 Gallons ** Receipt? (Y/N) y Receipt 2 Receipt? (Y/N) y 23 Receipt Gallons: Price/gallon: $2.56 Fuel cost: $58.88 Total: $58.88 ********* Thank You for Your Business! Welcome to Gas Station 2060 Do you have a discount card? (Y/N) Q To shut down pump 17 and get a report enter the pin 1234 Invalid pin number, enter the pin 2445 Shutting down... Pump 17 has been successfully shut down Total Gallons = 26 5/7 Total Sales = $66.26

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions