computer science program
COSC 1437 – Java Exam 2 (final)
Upload your completed .java source code file to “Submit Final Exam” link on Ecampus.
I would like to open a restaurant named MegaBites with computer-themed menu items. Start with the main program below and do the following: 1. Write the MenuItem class so the main program below will work.
2. Have the main program calculate the total calories of all menu items, total price of all menu items, and the highest priced item.
3. The output of the main program should be:
// main program
import java.util.*;
public class megabites
{
public static void main(String[] args)
{
ArrayList<MenuItem> Menu = new ArrayList<MenuItem>();
// parameters are Name, Category, Calories, Price
Menu.add(new MenuItem("Tera Burger", "Entrée", 600, 7.99));
Menu.add(new MenuItem("Micro-Soft Tacos", "Entrée", 500, 6.99));
Menu.add(new MenuItem("Spam", "Entrée", 1050, 2.99));
Menu.add(new MenuItem("Fish & Micro-Chips", "Entrée", 700, 8.99));
Menu.add(new MenuItem("Flash Fries", "Appetizer", 350, 1.99));
Menu.add(new MenuItem("Mouse", "Appetizer", 75, 0.99));
Menu.add(new MenuItem("Python", "Appetizer", 100, 1.99));
Menu.add(new MenuItem("Java", "Beverage", 150, 2.99));
Menu.add(new MenuItem("QWER-Tea", "Beverage", 50, 1.99));
Menu.add(new MenuItem("Deleted Cookie", "Dessert", 250, 1.99));
Menu.add(new MenuItem("Apple Crisps", "Dessert", 250, 1.99));
// calculate and output total calories, total prices, and highest price here
}
}
// add the MenuItem class here