Question
Add these to the program: Invalid number of minutes Invalid client type We will add two more types. Educational customer (e.g., a school) will use
Add these to the program: Invalid number of minutes Invalid client type
We will add two more types. Educational customer (e.g., a school) will use a type of e and will be charged
a flat 18 cents per minute.
The second new type is a preferred customer, which will be denoted as p, this type of account pays $10 as a
base charge and 6 cents per all minutes. However, if the preferred customer exceeds 500 total minutes, then
the rate for all minutes after the 500th minute is 4 cents per minute (the base stays at $10 no matter what the
minutes are).
The final alteration to the program will be to modify the
commercial customer
(from part 3 of the lab) by
giving a 30% discount for any customer who has been given a bonus status
and
who has reached at least
300 minutes. This modification will require an additional input only for commercial customers with 300
minutes or above. You will need to add another variable called
bonus
(you can make this a String or a char)
which, if (and only if) the customer is a commercial customer of 300 minutes or more, will be input from the
user (yes/no for a String, y/n for a char). To clarify, the only time this information will be entered is
when the customer type is commercial and they have used >= 300 total minutes, otherwise you do not need to
check for a bonus status.
Only commercial customers with 300 or more minutes are eligible for this bonus discount. Save, compile and
run your program on the data in the table below to check your work (some of the correct results are given to
you). Make sure your output always states the users type, the number of minutes, if a bonus applied (only to
the commercial type with >= 300 minutes) and what the cost is for their total bill. Collect the user input and
the corresponding program output for all of these examples into a single text file or add it in a large comment
section to the program file as we have previously done.
import java.util.Scanner; public class Program5A { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter customerType(r or c): "); char customerType = input.next().charAt(0); System.out.print("Enter num of min: "); int minutes = input.nextInt(); double total = 0; if (customerType == 'r') { // residential if (minutes <= 60) { total = 5; } else {// residential minutes over 60 here total = 0.10 * minutes; } } else if (customerType == 'c') { if (minutes <= 300) { total = 0.20 * minutes; } else { total = 0.15 * minutes; } } System.out.printf("Total = $%.2f ", total); input.close(); } }
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