Question: Write a program that 1. Creates 3 food products (objects of type food) 2. Maintains each food type's name and cost 3. Prints each food
Write a program that 1. Creates 3 food products (objects of type food) 2. Maintains each food type's name and cost 3. Prints each food type's name and cost 4. Calculates and prints the cost of all 3 foods Your program should have 1. A class called food that has 2 instance variables called type (that stores the name of the food) and cost (that holds the price of the food) 2. A class foodTest that has the main method -Be sure to create a header (see lab syllabus) and add comments /*Assignment title (i.e., Lab 10-Programming Test) Description (paraphrased description of program, do not just copy assignment text) Authors: Author name Date: date submitted Do not get any input from the user -To compile use javac foodTest.java -To run use java foodTest -Your program must be marked complete by 10:20am Example input type cost banaba 1.98 chips 2.73 steak 7.99 The output should be formatted as follows: banana: 1.98 chips: 2.73 steak: 7.99 Total cost: 12.70
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
