Question: Please help me finish this with these requirements. Below is the text of assignment 5 that you need to completed as well. import java.io.*; //to



![class Assignment5 { public static void main (String[] args) { char input1;](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f0dbfcdcd91_98866f0dbfc6153c.jpg)








Please help me finish this with these requirements. Below is the text of assignment 5 that you need to completed as well.
import java.io.*; //to use InputStreamReader and BufferedReader import java.util.*; //to use ArrayList
public class Assignment5 { public static void main (String[] args) { char input1; String inputInfo = new String(); String line = new String(); boolean operation;
// ArrayList object is used to store lamp objects ArrayList
try { printMenu(); // print out menu
// create a BufferedReader object to read input from a keyboard InputStreamReader isr = new InputStreamReader (System.in); BufferedReader stdin = new BufferedReader (isr);
do { System.out.println("What action would you like to perform?"); line = stdin.readLine().trim(); input1 = line.charAt(0); input1 = Character.toUpperCase(input1);
if (line.length() == 1) { switch (input1) { case 'A': //Add Lamp System.out.print("Please enter a lamp information to add: "); inputInfo = stdin.readLine().trim(); /*********************************************************************************** *** ADD your code here to create an object of one of child classes of Lamp class *** and add it to the lampList ***********************************************************************************/ Lamp lamp = LampParser.parseStringToLamp(inputInfo); lampList.add(lamp); break; case 'C': //Compute Total Prices /*********************************************************************************** *** ADD your code here to compute the total price for each lamp in the lampList. ***********************************************************************************/ for(int i =0; i } if (operation == true) System.out.print("lamp found "); else System.out.print("lamp not found "); break; case 'L': //List Lamps /*********************************************************************************** *** ADD your code here to print out all lamp objects. If there is no lamp, *** print "no lamp " ***********************************************************************************/ for(int i = 0; i } if(lampList.size()==0) System.out.print("no lamp "); break; case 'Q': //Quit break; case '?': //Display Menu printMenu(); break; default: System.out.print("Unknown action "); break; } } else { System.out.print("Unknown action "); } } while (input1 != 'Q'); // stop the loop when Q is read } catch (IOException exception) { System.out.println("IO Exception"); } } /** The method printMenu displays the menu to a use **/ public static void printMenu() { System.out.print("Choice\t\tAction " + "------\t\t------ " + "A\t\tAdd Lamp " + "C\t\tCompute Total Prices " + "D\t\tSearch for Lamp " + "L\t\tList Lamps " + "Q\t\tQuit " + "?\t\tDisplay Help "); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
