Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java solution To start, display a welcome message Welcome to NOVA Gas. Then, use a sentinel value loop to ask the user to enter NOVAGas
Java solution
To start, display a welcome message Welcome to NOVA Gas. Then, use a sentinel value loop to ask the user to enter NOVAGas to run the program like so: Enter NOVAGas to start filling up or Goodbye to quit. Be sure to use lower or upper string functions to change the value entered by the user to either lower case or upper case according to your choice so that you only have to test for either lower case or upper case in your while loop. Once you enter the loop, ask the user to input a credit or debit card number. Be sure to use a string function to validate the credit card number to ensure that it is between 15 and 16 digits long. Invalid. Credit card #23 must be either 15 or 16 digits in length: Also, convert the string to a list of characters and then check each character to see if it is a digit using the isDigit() function. We will work on an example in class. If something other than digits 0-9 appear, list the following error message: Invalid. Credit card %23 must contain digits. Please try again: Once you get a valid credit card number, let the user know that they can purchase a car wash and get a 5 cent discount for every gallon purchased. Then ask the user if they want to purchase a car wash. Be sure to use an upper case char function to convert to upper case for easier testing. See below: If you purchase a car wash, your price per gallon is reduced by 5 cents. Car Wash (Y/N)? Y After the user enters a choice for the car wash, display a menu showing the fuel types and prices, then accept the user input for the type of fuel they want to purchase. Be sure to use an upper case char function to convert to upper case for easier testing. See below: Please choose from the following fuel types: (R) egular $3.351 per gallon. (M) id-Grade $3.720 per gallon. (P) remium $4.042 per gallon. (D) iesel $3.797 per gallon. With a while loop, validate the fuel types to ensure that they are either R, M, P, D. If they choose a letter that is not R, M, P, D, display a message like the below and allow them to input the fuel type again:
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