Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Check the sample output to know how the results need to be printed. Read every instruction carefully and follow them strictly. Do not change the

  • Check the sample output to know how the results need to be printed.
  • Read every instruction carefully and follow them strictly.
  • Do not change the name of the attributes, and methods given below.
  • You are required to validate several values that user will enter through the console. Write your code in the Driver class in such a way that it passes all the possible test cases.
  • Mobile provider names should be a string. Three provider names: AT&T, TMOBILE, and VERIZON
  • Users can't be zero or between 2 and 5 in case of several users.
  • User cannot be a member of the (1) Mobile Alliance, (2) First Time User and (3) has Coupon at a time. You can ONLY have discount (1), (2) or (3).

  1. Attributes are given in this table. You must use the names given here, with the same capitalization as shown here. All attributes must be private.

Attribute Type Attribute Description
providerName String Provider Name
numOfUsers int Number of users
isMemberOfMobileAlliance Boolean Does the user have a membership with the mobile alliance?
isFirstTimeUser char Is the first time? "Y" or "N" (upper-case)
hasCoupon String Does the user have a coupon? "YES", or "No" (upper-case, lower-case or any combination of upper-case and lower-case)
COUPON double Must be declared as a constant and initialized with 5.00 ($5 coupon)
SALETAXES double Must be declared as a constant and initialized with 7.50 (7.5% sales tax)

  1. You can refer to the below tables for the information about the providers and discounts

Service Provider Category No. of users = 1 No. of users = 2 No. of Items between 3 and 5.
AT&T $30.99 per month $52.99 20.99 per user
T-MOBILE $39.99 per month $70.99 29.99 per user
VERIZON $43.99 per month $75.99 33.99 per user
Membership Discount 7.5% 6.5% 8.5%
First Time User Discount 10% 5% 4%
Coupon Discount $5 $5 $5
Sales Tax 7.5% 7.5% 7.5%

  1. Constructor: There will be only one constructor. It has the following signature:

public ProviderCalculator (String ProviderName, int numOfUser, boolean isMemberOfMobileAlliance, Char isFirstTimeUser, String hasCoupon) {..........}

  1. Methods:

You need to write the following methods, which are described below.

  1. Write getter and setter methods for all private instance variables.

  1. Write toString method which should be used to display the values for each attribute. This method should return a String. Please see the sample output for knowing the pattern.

  1. checkProviderName( ). This method accepts the name of the provider entered by the user and returns a Boolean whether the name is correct or no. Note.Use switch

  1. calcProviderPrice ( ): This method is private of return type double.It returns the provider price based on the provider's name and number of users. Refer the second table for more details.

Note: Use if-else conditions

  1. calcMembershipDiscount( ):This method is private of return type double and returns the membership discount based on the number of users if the user has membership. Otherwise, return 0.0. Refer the second table for more details.

  1. calcFirstTimeUserDiscount( ):This method is private of return type double and returns the first time user discount based on the number of users if the user is a first time user. Otherwise, it returns 0.0. Refer the second table for more details.

  1. Constraints:A user can use ONLY one of the following as discount:

1. Membership discount

2. Coupon discount

3. First time shopper discount

Therefore write another method called chooseYourDiscount( )which acceptthree parameters, isMemberOfMobileAlliance, isFirstTimeUser, and hasCoupon. This method should return a value of type double indicating the discount that the user has chosen based on the options displayed to the user and its respective answer. Make sure to respect the constraints as stated in f).

  1. calcCouponDiscount(): This method is private of return type double and returns the coupon discount if user has coupon. Otherwise, return 0.0. Refer the second table for more details.

  1. totalPrice(): This method is private of return type double and returns the price based on the membership, first time user, and coupon. Refer the second table for more details.

  1. totalPriceWithSalesTax(): This method is private of return type double and returns total price with tax. Refer the second table for more details.

  1. printReceipt(): This method is public of return type String and returns the receipt.

  1. Include Javadoc comments, using the @author, @param, and @return annotations when appropriate.

  1. Generate documentation for your project by clicking on Run from the NetBeans menu bar and then selecting Generate Javadoc. The documentation will be placed in a javadoc subfolder of the subfolder inside your project folder. To view the documentation, open the index.html file that is created.

Driver Class

Instructions:

  • Create a class named MobileDriver. This class has a method main and uses one Scanner object to read input from the console.
  • Please review the sample output and print the necessary statements in the same format.
  • Review the sample output and read the input values from the console appropriately.
  • Prompt the user for displaying items.

Sample validations:

All the validations should be done while reading the input in Driver class

  1. If the provider category is other than AT&T, T-Mobile, and VERIZON
  2. Then print below message.

"Not a valid provider's name"

  1. If the number of users is zero. Then print below message.

"The number of users can't be zero."

  1. In case of many users: The number of users should be between 3 and 5. Otherwise Print the message.

"The numberof users should be between 3 and 5.

  1. Only one of the following options will be used
  2. Membership discount
  3. Coupon discount
  4. First time shopper discount

  1. If any two of the above are used, then print below message.
  2. "User can only choose one option:a) Membership discount, b) Coupon discount, or c) First time shopper discount.

  1. At the end print "Please try again" message

  1. Below input has two mistakes. One is user cannot be a member and first time user at a time. Another one is passenger number can't be zero. Then you should print appropriate messages. Please check the below sample output.

Note : User input is in Red

Sample#1 of input/output:

Enter User Details:

Select the provider's name: AT&T, T-Mobile, Verizon: AT&T

How many number of users? 0

Are you a member of the Mobile Alliance? true

Are you a first time user? Y

Do you have coupon? Yes

*******************************

The output should look somehow as below:

Error#1: The number of users should not be zero.

Error#2: User can only use one discount, (1) Member of the Mobile Alliance, (2) First Time User, or (3) has a coupon at a time.

You are required to choose only one option: (1), (2) or (3)

Sample#2 of input/output:

Enter User Details:

Select the provider's name: AT&T, T-Mobile, Verizon: ATT

How many number of users? 6

Are you a member of the Mobile Alliance? false

Are you a first time user? N

Do you have coupon? Yes

Error#1: The provider's name ATT does not match the providers' list

Error#2: the number of users should be between 3 and 5.

Error#3: User can only use one discount, (1) Member of the Mobile Alliance, (2) First Time User, or (3) has a coupon at a time.

You are required to choose only one option: (1), (2), or (3).

Sample#3 of input/output:

Enter User Details:

Select the provider's name: AT&T, T-Mobile, Verizon: AT&T

How many numbers of users? 1

Are you a member of the Mobile Alliance? true

Are you a first-time user? No

Do you have coupon? N

Output: Refer below sample output 3

Sample#4 of input/output:

Enter User Details:

Select the provider's name: AT&T, T-Mobile, Verizon: T-Mobile

How many numbers of users? 3

Are you a member of the Mobile Alliance? false

Are you a first-time user? Yes

Do you have coupon? N

Output: Refer below sample output 4

Sample#5 of input/output:

Enter User Details:

Select the provider's name: AT&T, T-Mobile, Verizon: Verizon

How many numbers of users? 2

Are you a member of the Mobile Alliance? false

Are you a first time user? No

Do you have coupon? Y

Output: Refer below sample output-5

  • Invoke printReceipt()to print the customer invoice.

Hint: All the validations should be done while reading the input in Driver class.

Sample output 3:

Enter User Details:

-> Select the provider's name: AT&T, T-Mobile, Verizon: AT&T

-> How many number of users: 1

-> Are you a member of the Mobile Alliance: true

-> Are you a first time user: No

-> Do you have coupon: N

*******************************

User Provider Details:

Provider: AT&T

Number of user: 1

Member of the Mobile Alliance: true

first time user: No

have coupon: N

*******************************

  • ++++ Receipt ++++
  • Mobile Charges for 1 user using AT&T as provider is: $30.99
  • Member of the Mobile Alliance: $2.32
  • First Time user discount: $0.0
  • Coupon Discount: $0.0
  • Charges After applying Discount: $28.67
  • Total Price with Tax:$30.82

Sample Output 4

Enter User Details:

-> Select the provider's name: AT&T, T-Mobile, Verizon: T-Mobile

-> How many number of users: 3

-> Are you a member of the Mobile Alliance: false

-> Are you a first time user: Yes

-> Do you have coupon: N

*******************************

User Provider Details:

Provider: T-Mobile

Number of user: 3

Member of the Mobile Alliance: false

first time user: Yes

have coupon: N

*******************************

  • ++++ Receipt ++++
  • Mobile Charges for 3 user using T-Mobile as provider is: $29.99
  • Member of the Mobile Alliance: $0.0
  • First Time user discount: $1.19
  • Coupon Discount: $0.0
  • Charges After applying Discount: $28.80
  • Total Price with Tax:$30.96

Sample Output 5

Enter User Details:

-> Select the provider's name: AT&T, T-Mobile, Verizon: Verizon

-> How many number of users: 2

-> Are you a member of the Mobile Alliance: false

-> Are you a first time user: No

-> Do you have coupon: Y

*******************************

User Provider Details:

Provider: Verizon

Number of user: 2

Member of the Mobile Alliance: false

first time user: No

have coupon: Y

*******************************

  • ++++ Receipt ++++
  • Mobile Charges for 2 user using Verizon as provider is: $75.99
  • Member of the Mobile Alliance: $0.0
  • First Time user discount: $0.0
  • Coupon Discount: $5.0
  • Charges After applying Discount: $70.99
  • Total Price with Tax:$76.31

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

Management And Organisational Behaviour

Authors: Laurie Mullins

7th Edition

0273688766, 978-0273688761

More Books

Students also viewed these Programming questions

Question

Do I want people to be more like me?

Answered: 1 week ago