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

To do in Java: Write a program named RetailItem.java. Complete the blueprint for

ID: 3905407 • Letter: T

Question

To do in Java: Write a program named RetailItem.java.  

Complete the blueprint for ReatilItem.java. Then write a RetailDriver.java that creates the following three objects

Description

Units On Hand

Price

Jacket

12

59.95

Designer Jeans

40

34.95

Shirt

20

24.95

Then have your program print out the toString(), something like

The inventory currently has 12 Jacket which costs $59.95 for each unit for a total of $719.40

The inventory currently has 40 Designer Jeans which costs $34.95 for each unit for a total of $1,398.00

The inventory currently has 20 Shirt which costs $24.95 for each unit for a total of $499.00

Description

Units On Hand

Price

Jacket

12

59.95

Designer Jeans

40

34.95

Shirt

20

24.95

Explanation / Answer

class Retailer{

// variables of the class

String desc;

int units;

double price;

// constructor to set values

public Retailer(String desc, int units, double price)

{

this.desc = desc;

this.units = units;

this.price = price;

}

public String toString()

{

// formatting and returning the string

return String.format("The inventory currently has %d %s which costs $%.2f for each unit for a total of $%.2f", this.units, this.desc, price, units*price);

}

}

class Main {

public static void main(String[] args) {

Retailer Retailer("Jacket", 12,59.95);

Retailer two = new Retailer("Designer Jeans", 40,34.95);

Retailer three = new Retailer("Shirt", 20, 24.95);

System.out.println(one.toString());

System.out.println(two.toString());

System.out.println(three.toString());

}

}

/* SAMPLE OUTPUT

The inventory currently has 12 Jacket which costs $59.95 for each unit for a total of $719.40

The inventory currently has 40 Designer Jeans which costs $34.95 for each unit for a total of $1398.00

The inventory currently has 20 Shirt which costs $24.95 for each unit for a total of $499.00

*/

class Retailer{

// variables of the class

String desc;

int units;

double price;

// constructor to set values

public Retailer(String desc, int units, double price)

{

this.desc = desc;

this.units = units;

this.price = price;

}

public String toString()

{

// formatting and returning the string

return String.format("The inventory currently has %d %s which costs $%.2f for each unit for a total of $%.2f", this.units, this.desc, price, units*price);

}

}

class Main {

public static void main(String[] args) {

Retailer Retailer("Jacket", 12,59.95);

Retailer two = new Retailer("Designer Jeans", 40,34.95);

Retailer three = new Retailer("Shirt", 20, 24.95);

System.out.println(one.toString());

System.out.println(two.toString());

System.out.println(three.toString());

}

}

/* SAMPLE OUTPUT

The inventory currently has 12 Jacket which costs $59.95 for each unit for a total of $719.40

The inventory currently has 40 Designer Jeans which costs $34.95 for each unit for a total of $1398.00

The inventory currently has 20 Shirt which costs $24.95 for each unit for a total of $499.00

*/

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