Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a Java program that calculates sales price using while loop. Your program will prompt the user for information about two parameters: membership ID(data type:
Write a Java program that calculates sales price using while loop. Your program will prompt the user for information about two parameters: membership ID(data type: String and uses only upper-case letter) and input double number of price. (10 points) 1) In your main method, ask user to type membership ID, then send to a method to determine "valid" or "invalid". 2) One method should receive membership ID from main method, then return either true (valid) or false (invalid) to the main method 3) User ID must be 5 digits-length and the first char must be the same as the last char. 4) If user typed wrong ID, ask user to input ID again. 5) If the user input 00000 for the ID, then your program will terminate with "Good Bye!" message. 6) Otherwise your program does run repeatedly. 7) If the membership ID is valid, ask user to input price, then send to a method membership ID and price to calculate payment. 8) One method should receive the parameters (method membership ID and price) and return how much money to pay to buy the good. 9) The customer should receive discount of 10% from the original price if membership ID starts with 'A' For example, if a method received ("A301A", 100.0), the method should return 90.0. (eg: 100.0 - (100.0* 0.1) = 90.0) 10) When you print out sales price in main method, use ONLY ONE decimal point (eg: 90.0) and $ sign. 11) Include appropriate program documentation and formatting including: Your first and last name Your contact information Your student ID number The date A short description of the program's function Comments necessary to explain the operation of your program Proper indentation [Important!] You must create one method to check membership ID and another method to calculate payment. Those method must return its result to main method. Sample log of execution: (This is not a desired output!! Just a SAMPLE] ID? A301 Wrong ID, please input ID again. ID? A301B Wrong ID, please input ID again. ID? A301A Price? 100.0 You pay : $90.0 ID? C500C Price? 100.0 You pay : $100.0 ID? 00000 Good Bye
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