Answered step by step
Verified Expert Solution
Link Copied!

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 _

1. Declare a double variable called total2. Declare a double variable called gallons3. Declare a char variable called payment_type4. Declare a double variable called cost.Initialize this value to 2.555. Declare a bool variable called authorized. Initialize this value to false.6. Ask the user the type of payment that will be made. Use the payment_type variable to receive this user input.7. If the user enters a 'c', it will be a credit card payment1. 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)2. Write a nested-if statement and check that the value of the zipcode entered is 93301. If the zipcode entered is correct, set authorized to true.8. If the user enters a 'd', it will be a debit card payment.1. 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)2. Write a nested-if statement and check that the value of the PIN entered is 1234. If the PIN entered is correct, set authorized to true and change the value of cost to 2.35.9. If authorized is true, only then will you do the following:1. Ask the user how many gallons are being purchased. User will enter a numeric amount. Use gallons variable to hold this amount.2. 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 0.35 to the total cost for debit card purchases.3. Display the cost of the purchase to the user.10. 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

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

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

What are special allocations. AppendixLO1

Answered: 1 week ago