Question: Assignment 3 A cafeteria receives orders in text files named ( order# . txt ) . Where # is the order number starting from 1
Assignment
A cafeteria receives orders in text files named order#txt Where # is the order number starting from For example ordertxt ordertxt ordertxt 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 inputs:
TYPE MAININGREDIENT SIZE
TYPE can be Juice or Sandwich.
SIZE can be SMALL, MEDIUM, or LARGE.
MAININGREDIENT can be any single word ingredient, it is not important.
Answer the following questions:
Q points: Write a Java program to loop over all the order files starting from ordertxt 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 ordertxt and it does not exist, this means that ordertxt was the last order, and you can break out of the loop.
Q points: Compute the total income from all the orders and print it to the screen. Use the following information to compute the income:
tableTYPEpriceSandwichJuice
tableSIZEpriceSMALLMEDIUMLARGE
The total price for each item is TYPEprice SIZEprice
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
