Question: Assignment 3 A cafeteria receives orders in text files named ( order# . txt ) . Where # is the order number starting from 1

Assignment 3
A cafeteria receives orders in text files named (order#.txt). Where # is the order number starting from 1. For example (order1.txt order2.txt order3.txt ... orderN.txt). Where N is the last order number and it is not known when the code is executed.
The following is an example of an order file:
Juice Apple SMALL
Sandwich Beef LARGE
Sandwich Chicken MEDIUM
The order file can contain one line or more, each line contains 3 inputs:
TYPE MAIN_INGREDIENT SIZE
TYPE can be Juice or Sandwich.
SIZE can be SMALL, MEDIUM, or LARGE.
MAIN_INGREDIENT can be any single word ingredient, it is not important.
Answer the following questions:
Q1(6 points): Write a Java program to loop over all the order files starting from order1.txt until the last order. HINT: You can check if you reached the last file by using the exists () method from the class File. If for example your loop reaches order10.txt and it does not exist, this means that order9.txt was the last order, and you can break out of the loop.
Q2(4 points): Compute the total income from all the orders and print it to the screen. Use the following information to compute the income:
\table[[TYPE,price],[Sandwich,0.5],[Juice,0.3]]
\table[[SIZE,price],[SMALL,0.0],[MEDIUM,0.3],[LARGE,0.5]]
The total price for each item is TYPE_price + SIZE_price
Assignment 3 A cafeteria receives orders in text

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 Programming Questions!