The Secondhand Rose Resale Shop is having a seven-day sale during which the pric
ID: 3834487 • Letter: T
Question
The Secondhand Rose Resale Shop is having a seven-day sale during which the price of any unsold item drops 10 percent each day. Design a class diagram showing the class, the application program, the relationship between the two, and multiplicity. Then write the Java code as described below.
1. The Secondhand Rose Resale Shop is having a seven-day sale during which the price of any unsold item drops 10 percent each day. Design a class diagram showing the class, the application program, the relationship between the two, and multiplicity. Then write the Java code as described below. a. An Inventory class that contains an item number and the original price of the item Include the following: i. A default constructor that initializes each attribute to some reasonable default value for a non-existent inventory item. ii. Another constructor method that has a parameter for each data member, called the overloaded constructor. This constructor initializes each attribute to the value provided when an object of this type is instantiated. Be sure to incorporate adequate error checking for all numeric attributes. iii. Accessor and mutator methods for each attribute. Be sure to incorporate adequate error checking for all numeric attributes. b. An application program that contains two methods: the maino module and the 0module. The mainomodule must do the following create an Inventory object using the default constructor i. use a loop to get inventory items from the user. The user should enter the item number and the original price of the item. This loop should continue until the user indicates that they have no more items to enter. For each item entered by the user, the code inside the loop should do the following 2 items: iii. set the attributes of the Inventory object by calling the appropriate method in the Inventory class for each item entered by the user iv. send the Inventory items, one at a time, to the module for processing The print odule must accept an Inventory object and produce a report that shows the item number and the price of an inventory item on each day of the sale, one through seven, using a loop. For example, an item with an original price of S10.00 costs 10 percent less, or $9.00, on the first day of the sale. On the second day of the sale, the same item is 10 percent less than $9.00, or S8.10Explanation / Answer
Kindly find the below-working code for the above problem statement:
****************
Inventory.java
package com.sagar.oracle;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class Inventory {
static double item_number;
static double original_price;
//Empty constructor
public Inventory() {
super();
}
//Overloaded constructor
public double getItem_number() {
return item_number;
}
//Accessors and mutators
public void setItem_number(double item_number) {
this.item_number = item_number;
}
public double getOriginal_price() {
return original_price;
}
public void setOriginal_price(double original_price) {
this.original_price = original_price;
}
}
*****************
Application Program.java
package com.sagar.oracle;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class ApplicationProgram {
Inventory inventory;
static Scanner scanner;
static double item_number;
static double original_price_of_the_item;
public ApplicationProgram() {
super();
}
public Inventory getInventory() {
return inventory;
}
public void setInventory(Inventory inventory) {
this.inventory = inventory;
}
public static Scanner getScanner() {
return scanner;
}
public static void setScanner(Scanner scanner) {
ApplicationProgram.scanner = scanner;
}
public static double getItem_number() {
return item_number;
}
public static void setItem_number(double item_number) {
ApplicationProgram.item_number = item_number;
}
public static double getOriginal_price_of_the_item() {
return original_price_of_the_item;
}
public static void setOriginal_price_of_the_item(
double original_price_of_the_item) {
ApplicationProgram.original_price_of_the_item = original_price_of_the_item;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
List<String> records = new ArrayList<String>();//Create the array list for the text records to be read
int count = 0;
while(count!=0)
scanner=new Scanner(System.in);
System.out.println("Enter the item_number from the user");
item_number= scanner.nextDouble();
records.add(String.valueOf(item_number));
System.out.println("Enter the original price of the item");
original_price_of_the_item=scanner.nextDouble();
records.add(String.valueOf(original_price_of_the_item));
printSaleData();//processing the data
}
private static void printSaleData() {
// TODO Auto-generated method stub
if(item_number <= 7 && original_price_of_the_item<=7)
{
//Print the reports
//below is the function for the example of printing the report
if(item_number == 10.00 || item_number <=9.00){
System.out.println("First day of the sale");
}
else if(item_number == 9.00 || item_number <=8.10){
System.out.println("Second day of the sale");
}
}
}
}
********************
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.