Question: Java Project You plan to open a cafe that will have a computer available for customers to place orders. You plan to have a limited

Java Project

You plan to open a cafe that will have a computer available for customers to place orders. You plan to have a limited menu selection available that includes coffees and flavors. You want customers to select their choices from a list of available items and options. The application must show the price of each item.

The following is a brief requirement description with sample outputs.

1. Selecting Coffee (20 points)

When the program starts, it first shows a list/menu of coffees and their prices, then asks a user to select a type of coffee by entering one integer. A sample output is as follows.

=== Select Coffee ===

1. Iced Coffee Single $3.00

2. Iced Coffee Double $3.50

3. Cappuccino Single $3.50

4. Cappuccino Double $4.00

5. Latte Single $3.50

6. Latte Double $4.00

Select Coffee [1-6]: 1

You are supposed to validate the input.

If the user enters a letter or a number not between 1 and 6, the user will see an error message.

A sample output for invalid number is as follows.

Select Coffee [1-6]: a

Error! You need to enter a number!

Select Coffee [1-6]:

Select Coffee [1-6]: 7

Error! You need to enter a number between 1 and 6!

Select Coffee [1-6]:

In your program, you can hard-code the information for Coffee (i.e., coffee names and prices) shown above, such as 1. Iced Coffee Single $3.00 and use the hard-code price, such as $3.0, for calculation of a total price of the order.

2. Additional Charge (25 points)

After the user provides a right coffee number for coffee selection, the program asks the user to select flavor. A sample output is as follows.

=== Select Additional: ===

1. Cream $0.0

2. Sugar $0.0

3. Almond $0.50

4. Banana $0.50

5. Cinnamon $1.00

6. Cherry $1.50

7. No More flavors!

You can hard-code the additional charge information as shown above, such as 1.Cream $0.0 and use the hard-code price, such as 0.00, for calculation of the total price of the order.

After the user makes a choice for flavors, such as 3 for Almond. The program will repeat this option for user to have multiple flavors for one coffee. If the user have no more flavors to be added, just enter 7 to quit flavor selection.

The user can enter 7 to quit vegetable selection. A sample output is as follows.

=== Select Additional: ===

1. Cream $0.0

2. Sugar $0.0

3. Almond $0.50

4. Banana $0.50

5. Cinnamon $1.00

6. Cherry $1.50

7. No More flavors!

Select Flavor [1-7]: 3

=== Select Additional: ===

1. Cream $0.0

2. Sugar $0.0

3. Almond $0.50

4. Banana $0.50

5. Cinnamon $1.00

6. Cherry $1.50

7. No More flavors!

Select Flavor [1-7]: 7

3. Entering a customers name (10 points)

After finishing flavor selection, the program asks for the users name so that the user can enter text like Tom or Tom Smith.

Enter customer's name: Tom Smith

4. Displaying and writing order information (20 points)

After entering a name, the program displays details for this order line on computer monitor. The order details includes six fields: date and time, customer name, coffee name, flavors, and a formatted total price separated by a tab /t. Flavors are separated by a comma ,.

A sample output to the monitor is as follows.

Enter customer's name: Tom Smith

Nov 25, 2017 10:35:43 AM Tom Smith Latte Single, Sugar,Almond,Banana $4.50

Continue to order more? (y/n):

For your reference, the date and time is created by the following statements.

Date now = new Date();

DateFormat defaultDate = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);

String time = defaultDate.format(now);

Besides showing on monitor, the same order line content is written (appended) to a text file named receipt.txt and each order occupies one line in the text file. Here is a specific example for an order in the receipt.txt.

Nov 25, 2017 10:35:43 AM Tom Smith Latte Single, Sugar,Almond,Banana $4.50

Your program needs to create the output file, named receipt.txt, if it doesnt exist yet, and later appends (not overwrite) order information to the file. So next time when your program is executed, new order information will be appended to the receipt.txt file. You must use a relative path when creating an output stream writer object.

For simplicity, we dont record any information about the sales clerk and one order includes only one cup of coffee.

5. Repeating the order process (15 points)

Continue to order more? (y/n):

If the user enters y or Y in the above prompt, the whole order process repeats by asking the user to select coffee, flavor and customer name.

Design requirements: (10 points)

You must have at least the following java classes. You may have additional classes if you want.

[1] a CoffeeOrder class to simulate the CoffeeOrder entity in real world, which has fields of coffeeName, flavor names, price of the coffee order, customer name, the string value of time stamp (refer to the prior sample code) and corresponding methods. This class also provides a method to append the content of an orders content to the output text file, receipt.txt. (CoffeeOrder.java)

[2] a java application, named CafeApp.java, that contains a main method. This class interacts with CoffeeOrder class.

Suggestions:

Start early and start from simple. For example, leaving the multiple flavor selections, the order repeat process, and writing to file, etc, to a later stage.

When incrementally improving your programs, make sure to keep a clean copy of your completed program. In case you couldnt complete the whole project in time, you can still submit a working solution of partial project and receive partial points.

Coffee Name = Iced Coffee

Price = $4.00

Class CoffeeOrder

{

private string coffeename

private double price;

private string [] flavorArray = new String [100];

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!