Question

Write a class named RetailItem that holds data about an item in a retail store. The...

Write a class named RetailItem that holds data about an item in a retail store. The class should store the following data in attributes: item description, unit sold, units in inventory, and price.

Once you have written the class, write a program that creates 5 RetailItem objects and stores the following data in them:

Description

Units Sold

Units in Inventory

Price

Item #1

Jacket

20

12

59.95

Item #2

Designer Jeans

150

40

34.95

Item #3

Shirt

230

20

24.95

Item #4

Short

310

30

15.95

Item #5

Hat

120

30

10.95

Sample Outputs

Retail Item 1:

Description: Jacket

Units sold: 20 Units in inventory: 12

Price: $59.95

Retail Item 2:

Description: Designer Jeans

Units sold: 150 Units in inventory: 40

Price: $34.95

etc

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;

class RetailItem
{
String description;
int unitsSold,unitsInInventory;
double price;

RetailItem(String d,int us,int ui,double p)
{
description=d;
unitsSold=us;
unitsInInventory=ui;
price=p;
}

public String toString()
{
return description+"\t\t\t"+unitsSold+"\t\t"+unitsInInventory+"\t\t\t"+price;
}

public static void main(String args[])
{
System.out.println("\n\n\t\t\tDescription\t\tUnits sold\tUnits in Inventory\tPrice\n");

RetailItem r1=new RetailItem("Jacket",20,12,59.95);
System.out.println("Item 1:\t\t\t"+r1);
RetailItem r2=new RetailItem("Designer Jeans",150,40,34.95);
System.out.println("Item 2:\t\t"+r2);
RetailItem r3=new RetailItem("Shirt",230,20,24.95);
System.out.println("Item 3:\t\t\t"+r3);
RetailItem r4=new RetailItem("Short",310,30,15.95);
System.out.println("Item 4:\t\t\t"+r4);
RetailItem r5=new RetailItem("Jacket",120,30,10.95);
System.out.println("Item 5:\t\t\t"+r5);
System.out.println("\n");
}
}

Add a comment
Know the answer?
Add Answer to:
Write a class named RetailItem that holds data about an item in a retail store. The...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in python Write a class named RetaiI_Item that holds data about an item in a retail...

    in python Write a class named RetaiI_Item that holds data about an item in a retail store. The class should store the following data in attributes: • Item Number • Item Description • Units in Inventory • Price Create another class named Cash_Register that can be used with the Retail_Item class. The Cash_Register class should be able to internally keep a list of Retail_Item objects. The class should include the following methods: • A method named purchase_item that accepts a...

  • Write a Gui programming by using JavaFx menus, stage and screen concepts to the RetailItem class,...

    Write a Gui programming by using JavaFx menus, stage and screen concepts to the RetailItem class, Write a class named Retailltem that holds data about an item in a retail store. The class should have the following fields description: The description field is a String object that holds a brief description of the item . unitsOnHand: The unitsOnHand field is an int variable that holds the number of units currently in inventory Price: The price field is a double that...

  • Week 6: Lab Overview TABLE OF CONTENTS Lab Overview Scenario/Summary Write a windows console application that...

    Week 6: Lab Overview TABLE OF CONTENTS Lab Overview Scenario/Summary Write a windows console application that holds data about an item in a retail store. Your class should be named RetailItem and should hold data about an item in a retail store. The class will have the following member variables. Description - string holding the description of the item, unitsOnHand - int that holds the number of units in inventory Price - double that holds the price of the item...

  • USE C++. Just want to confirm is this right~? Write a class named RetailItem that holds...

    USE C++. Just want to confirm is this right~? Write a class named RetailItem that holds data about an item in a retail store. The class should have the following member variables: description: A string that holds a brief description of the item. unitsOnHand: An int that holds thw number of units currently in inventory. price: A double that holds that item's retail price. Write the following functions: -appropriate mutator functions -appropriate accessor functions - a default constructor that sets:...

  • Programming Assignment 6: Object Oriented Programming Due date: Check Syllabus and Canvas Objectives: After successfully completing...

    Programming Assignment 6: Object Oriented Programming Due date: Check Syllabus and Canvas Objectives: After successfully completing this assignment, students will practice Object Oriented design and programming by creating a Java program that will implement Object Oriented basic concepts. RetailItem Class: Part 1: Write a class named RetailItem that holds data about an item in a retail store. The class should have the following fields: • description. The description field references a String object that holds a brief description of the...

  • Need this program in C#. Thank you 3/19 Lab11 PartC Dur Scenario/Summary Write a windows console...

    Need this program in C#. Thank you 3/19 Lab11 PartC Dur Scenario/Summary Write a windows console application that holds data about an item in a retail store. Your class should be named Retailltem and should hold data about an item in a retail store. The class will have the following member variables. Description- string holding the description of the item, unitsOnHand - int that holds the number of units in inventory Price - double that holds the price of the...

  • in java PART ONE ======================================= Below is the "RetailItem" class definition that we used in Chapter 6. Write a "CashRegister" class that leverages this "Ret...

    in java PART ONE ======================================= Below is the "RetailItem" class definition that we used in Chapter 6. Write a "CashRegister" class that leverages this "RetailItem" class which simulates the sale of a retail item. It should have a constructor that accepts a "RetailItem" object as an argument. The constructor should also accept an integer that represents the quantity of items being purchased. Your class should have these methods: getSubtotal: returns the subtotal of the sale, which is quantity times price....

  • C++ Retailltem.h, Retailltem.cpp, Store.h, Store.cpp, and Driver.cpp. Description: Write a set of programs that holds data...

    C++ Retailltem.h, Retailltem.cpp, Store.h, Store.cpp, and Driver.cpp. Description: Write a set of programs that holds data about items in a retail store. Your submission should include 5 files, Retailltem.b, Retailltem.cpp, Store, Store.cpp, and Driver.cpp 1. Retailltem class: The class should have three member variables • description (a string, represent the item's name. A name contains space) quantity (an int, represent how many current available) price (a double, item's price) Member Functions Constructor with default argument get Description getQuantity getPrice setDescription...

  • Inventory Program (C++) Write a program that uses a structure to store the following inventory data...

    Inventory Program (C++) Write a program that uses a structure to store the following inventory data in a file: - Item Description -Quantity on Hand -Wholesale cost -Retail cost -Date Added to Inventory The program should have a menu that allows the user to perform the following tasks: -Add new records to file -Display any record in the file -Change any record in the file Input Validation: The program should not accept quantities, or wholesale or retail costs, less than...

  • Object oriented design: Write a program that implements the basic flow, the startup scenario (For a retail store) a...

    Object oriented design: Write a program that implements the basic flow, the startup scenario (For a retail store) and the alternative flow: An item with the specified identifier has already been entered in the current sale. Program increases the sold quantity of the item, and presents item description, price, and running total. You do not have to program any other alternative flows or add any other functionality. You are also not required to code the view, you may replace the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT