Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The Savvy Consignment Resale Shop is having a 5-day sale during which the price

ID: 3710183 • Letter: T

Question

The Savvy Consignment Resale Shop is having a 5-day sale during which the price of any unsold item drops 5 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. Be sure to follow the CSI 115 Style criteria for naming conventions, class diagrams, pseudocode, keywords, and operators.

An Inventory class that contains:

an item number and the original price of the item. Include the following:

A default constructor that initializes each attribute to some reasonable default value for a non-existent inventory item.

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.

Accessor and mutator methods for each attribute. Be sure to incorporate adequate error checking for all numeric attributes.

An application program that contains two methods: the main() module and the printSaleData()module.

create an Inventory object using the default constructor

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:

set the attributes of the Inventory object by calling the appropriate method in the Inventory class for each item entered by the user

send the Inventory items, one at a time, to the printSaleData() module for processing

Extra credit for including Javadoc comments.

The main()module must do the following:

The printSaleData()module 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 $10.00 costs 5 percent less, or $9.50, on the first day of the sale. On the second day of the sale, the same item is 5 percent less than $9.50, or $9.02.

Explanation / Answer

Hi,
Here is the full code with comments
Main class

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Inventory inventory= new Inventory();

Scanner sc= new Scanner(System.in);

while(true)

{

System.out.println("please enter the detals of inventory items: ");

System.out.println(" please enter the item number: ");

inventory.setItemNUmber(sc.nextInt());

System.out.println(" please enter the price of above item : ");

inventory.setPrice(sc.nextInt());

printSaleData(inventory);

System.out.println("do you want to enter more items? Y:N");

String c= sc.nextLine();

if(c=="N")

break;

}

sc.close();

}

private static void printSaleData(Inventory inventory) {

System.out.println("The item number is: "+inventory.getItemNUmber());

System.out.println("The price of item is: "+inventory.getPrice());

}

}

public class Inventory {

double price;

int itemNUmber;

  

  

public Inventory() {

this.price = 0;

this.itemNUmber = 0;

}

  

public Inventory(double price, int itemNUmber) {

if(price>0)

this.price = price;

if(itemNUmber>0)

this.itemNUmber = itemNUmber;

}

public double getPrice() {

return price;

}

public void setPrice(double price) {

this.price = price;

}

public int getItemNUmber() {

return itemNUmber;

}

public void setItemNUmber(int itemNUmber) {

this.itemNUmber = itemNUmber;

}

  

}

Thumbs up if this was helpful, otherwise let me know in comments

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote