Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 . Declare a double variable called total 2 . Declare a double variable called gallons 3 . Declare a char variable called payment _
Declare a double variable called total Declare a double variable called gallons Declare a char variable called paymenttype Declare a double variable called cost.Initialize this value to Declare a bool variable called authorized. Initialize this value to false Ask the user the type of payment that will be made. Use the paymenttype variable to receive this user input If the user enters a c it will be a credit card payment Ask the user to enter a zipcode you will have to create a variable to store the value of the zipcode that the user enters; you decide what data type is appropriate Write a nestedif statement and check that the value of the zipcode entered is If the zipcode entered is correct, set authorized to true If the user enters a d it will be a debit card payment Ask the user to enter a PIN You will have to create a variable to store the value of the PIN that the user enters; you decide what data type is appropriate Write a nestedif statement and check that the value of the PIN entered is If the PIN entered is correct, set authorized to true and change the value of cost to If authorized is true, only then will you do the following: Ask the user how many gallons are being purchased. User will enter a numeric amount. Use gallons variable to hold this amount Calculate the appropriate total of the purchase depending on the payment type. Use the total variable to calculate the total amount.Additionally, you will need to add to the total cost for debit card purchases Display the cost of the purchase to the user Add an else block after checking if authorized is true. In this section, show an appropriate message indicating an invalid PIN or ZIP code In C code
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