Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

With the following code: import java.util.*; class work{ private static long serialnumber=999999; private String type; private String brand; private double price; work(String type,String brand,double price){

With the following code:

import java.util.*;

class work{ private static long serialnumber=999999; private String type; private String brand; private double price; work(String type,String brand,double price){ this.type=type; this.brand = brand; this.serialnumber = serialnumber; this.price = price; serialnumber++; } //Modify public void modify_type(String type1){ type=type1; System.out.println("Your type value is modified"); } public void modify_brand(String brand1){ brand=brand1; System.out.println("Your brand value is modified"); } public void modify_price(double price){ if(price

image text in transcribed

image text in transcribed

image text in transcribed

Part II) You are hired by a major appliance dealer to write a software that helps the store owner in acquiring and keeping track of appliances at the store. Write a driver program that will contain, at least, the following methods. Note: You can have the main function in a separate driver file, or in the same file if you prefer. 1. a main() method, that will: a. Display a welcome message; b. Prompt the store owner for the maximum number of appliances (maxAppliances) his/her store can contain (or wish to aquire; this is not a focus here). Create an empty array, called inventory, that will have the potential of keeping track of the created Appliance objects. c. Display a main menu (Figure 1) with the following choices and keep prompting the user until they enter a number between 1 and 5 inclusive (i.e invalid number will result in repeating the display of the main menu): What do you want to do? 1. Enter new appliances (password required) 2. Change information of an appliance (password required) 3. Display all appliances by a specific brand 4. Display all appliances under a certain a price. 5. Quit Please enter your choice > Figure 1. Main d. When option 1 is entered: i. Prompt the store owner for his/her password. (Make sure you have a constant variable containing the password "c249" - do not use any other password as it will be easier for the marker to check your assignments). The store owner has a maximum of 3 attempts to enter the correct password. After the 3r illegal entry, the main menu in Figure 1 is re- displayed again. Additionally after this process is repeated 4 consecutive times (i.e. total failed attempts is 12 consecutive attempts by now), the program must display the following messages: Program detected suspicious activities and will terminate immediately!", then the program must exits. ii. If the correct password is entered (which will reset the counter of failed attempts), ask the owner how many appliances he/she wants to enter. Check that there is enough space in the store (inventory array) to add these many appliances. If so, add them; otherwise inform the owner of the maximum remaining places in the array. (How the appliance information is input/entered by the user is up to you). e. When option 2 is entered: i. Prompt the store owner for his/her password. (Still, you should make sure the password is "c249" - do not use another password). Again the store owner has 3 attempts to enter the correct password. However, after the 3rd illegal entry, the main menu in Figure 1 is simply re-displayed again (notice the different behaviour in that case from the previous one above). ii. Ask the user of the serial number of the appliance he/she wishes to update. If there is no object with that serial number in the array inventory, display a message indicating that and ask the user if he/she wishes to re-enter another serial number, or quit this operation and go back to the main menu. If the entered serial number exists, display the current information of that appliance in the following format: Appliance Serial # XXXXXXX (where XXXXXXX is the serial number) Brand: brand of the appliance Type: type of the appliance Price: price Then ask the user which attribute he/she wishes to change by displaying the following menu. What information would you like to change? 1. brand Figure 2. Update 2. type 3. price 4. Quit Enter your choice > Once the user has entered a correct choice, ask the user for the new information and make the changes to the object attribute then display again all of the attributes on the screen to show that the change has taken place. Keep prompting the user for additional changes until the user enters 4 (indicating that he/she wishs to stop the update process). Each time the user is prompted for a choice, make sure that a number from 1 to 4 is entered, otherwise keep prompting until a valid number is entered. You should pay a special attention to the change when it comes to type, as the different types are specific and limited cannot be different than the types indicated in the initial description in Part I above). When option 3 (in the main menu shown in Fig. 1) is entered, prompt the user to enter a brand name. You then need to display the information of all appliances in the inventory with that brand. (Hint: You may use a static method, for instance called findAppliancesBy, which accepts a string for an brand name then performs the needed search). g. When option 4 (in the main menu shown in Figure 1) is entered, prompt the user to enter a value (representing a price). You then need to display all appliances in the store that have a price smaller than that entered value. (Hint: You may use a static method, for instance called findCheaperThan, which accepts a double value, for a price, then performs the needed search). h. When option 5 (in the main menu shown in Fig. 1) is entered, display a closing message and end the program. Part II) You are hired by a major appliance dealer to write a software that helps the store owner in acquiring and keeping track of appliances at the store. Write a driver program that will contain, at least, the following methods. Note: You can have the main function in a separate driver file, or in the same file if you prefer. 1. a main() method, that will: a. Display a welcome message; b. Prompt the store owner for the maximum number of appliances (maxAppliances) his/her store can contain (or wish to aquire; this is not a focus here). Create an empty array, called inventory, that will have the potential of keeping track of the created Appliance objects. c. Display a main menu (Figure 1) with the following choices and keep prompting the user until they enter a number between 1 and 5 inclusive (i.e invalid number will result in repeating the display of the main menu): What do you want to do? 1. Enter new appliances (password required) 2. Change information of an appliance (password required) 3. Display all appliances by a specific brand 4. Display all appliances under a certain a price. 5. Quit Please enter your choice > Figure 1. Main d. When option 1 is entered: i. Prompt the store owner for his/her password. (Make sure you have a constant variable containing the password "c249" - do not use any other password as it will be easier for the marker to check your assignments). The store owner has a maximum of 3 attempts to enter the correct password. After the 3r illegal entry, the main menu in Figure 1 is re- displayed again. Additionally after this process is repeated 4 consecutive times (i.e. total failed attempts is 12 consecutive attempts by now), the program must display the following messages: Program detected suspicious activities and will terminate immediately!", then the program must exits. ii. If the correct password is entered (which will reset the counter of failed attempts), ask the owner how many appliances he/she wants to enter. Check that there is enough space in the store (inventory array) to add these many appliances. If so, add them; otherwise inform the owner of the maximum remaining places in the array. (How the appliance information is input/entered by the user is up to you). e. When option 2 is entered: i. Prompt the store owner for his/her password. (Still, you should make sure the password is "c249" - do not use another password). Again the store owner has 3 attempts to enter the correct password. However, after the 3rd illegal entry, the main menu in Figure 1 is simply re-displayed again (notice the different behaviour in that case from the previous one above). ii. Ask the user of the serial number of the appliance he/she wishes to update. If there is no object with that serial number in the array inventory, display a message indicating that and ask the user if he/she wishes to re-enter another serial number, or quit this operation and go back to the main menu. If the entered serial number exists, display the current information of that appliance in the following format: Appliance Serial # XXXXXXX (where XXXXXXX is the serial number) Brand: brand of the appliance Type: type of the appliance Price: price Then ask the user which attribute he/she wishes to change by displaying the following menu. What information would you like to change? 1. brand Figure 2. Update 2. type 3. price 4. Quit Enter your choice > Once the user has entered a correct choice, ask the user for the new information and make the changes to the object attribute then display again all of the attributes on the screen to show that the change has taken place. Keep prompting the user for additional changes until the user enters 4 (indicating that he/she wishs to stop the update process). Each time the user is prompted for a choice, make sure that a number from 1 to 4 is entered, otherwise keep prompting until a valid number is entered. You should pay a special attention to the change when it comes to type, as the different types are specific and limited cannot be different than the types indicated in the initial description in Part I above). When option 3 (in the main menu shown in Fig. 1) is entered, prompt the user to enter a brand name. You then need to display the information of all appliances in the inventory with that brand. (Hint: You may use a static method, for instance called findAppliancesBy, which accepts a string for an brand name then performs the needed search). g. When option 4 (in the main menu shown in Figure 1) is entered, prompt the user to enter a value (representing a price). You then need to display all appliances in the store that have a price smaller than that entered value. (Hint: You may use a static method, for instance called findCheaperThan, which accepts a double value, for a price, then performs the needed search). h. When option 5 (in the main menu shown in Fig. 1) is entered, display a closing message and end the program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

Students also viewed these Databases questions

Question

What is the preferred personality?

Answered: 1 week ago

Question

What is the relationship between humans?

Answered: 1 week ago