Question
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 item You will need two constructors, one that will accept arguments for each member variable and one that will assign default values. You will also need to write mutator functions and accessor functions. Once you write the class, write a separate program that creates three Retailltem objects. The first one should use the default values, and the other two should have values assigned upon creation. The user should input the variables (testing for the units on hand and price greater than 0) Then, the program should display all three Retailltems. Finally, the program should tally the inventory for all three items and display it. Welcome to the Retail store! Price must be greater than 0. Please enter the price for item 1: 33 Inventory must be greater than 0. Please enter the units on hand for item 1: 10 Please enter the description for item 1: shirt Display all items Description: shirt Units on hand: 10 Price: $33.00
media%2Ff01%2Ff01a0157-750d-4d5f-8fe2-4c
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class RetailItem
{
// variables declaration
string description;
int unitsOnHand;
double price;
// getter and setter for description
public string Description
{
get { return description; }
set { description = value; }
}

// getter and setter for unitsOnHand
public int UnitsOnHand
{
get { return unitsOnHand; }
set { unitsOnHand = value; }
}
// getter and setter for price
public double Price
{
get { return price; }
set { price = value; }
}
// parameterized constructor
public RetailItem(String description, int unitsOnHand, double price)
{
this.description = description;
this.unitsOnHand = unitsOnHand;
this.price = price;
}
// default constructor
public RetailItem()
{
this.description = "";
this.unitsOnHand = 0;
this.price = 0;
}

}
class Program
{
static void Main(string[] args)
{
// creating object of ReatilItem class using default constructor
RetailItem item1 = new RetailItem();
Console.WriteLine("Welcome to the Retail store!");
Console.WriteLine("Price must be greater then 0.");
Console.Write("Please enter the price for item 1: ");
// getting price from user
double price = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Inventory must be greater then 0.");
Console.Write("Please enter units on hand for item 1: ");
// getting inventory from user
int unitsOnHand = Convert.ToInt32(Console.ReadLine());
Console.Write("Please enter the description for item 1: ");
// getting description from user
string description = Console.ReadLine();
// set the data
item1.Description = description;
item1.UnitsOnHand = unitsOnHand;
item1.Price = price;
// creating object of ReatilItem class using paramterized constructor
RetailItem item2 = new RetailItem("Jeans",40,34.95);
// creating object of ReatilItem class using paramterized constructor
RetailItem item3 = new RetailItem("Long sleeve shirt",20,24.95);
Console.WriteLine("\nDisplay all items");
Console.WriteLine("\nDescription: " + item1.Description);
Console.WriteLine("Units on hand: " + item1.UnitsOnHand);
Console.WriteLine("Price: $" + item1.Price);
Console.WriteLine("\nDescription: " + item2.Description);
Console.WriteLine("Units on hand: " + item2.UnitsOnHand);
Console.WriteLine("Price: $" + item2.Price);
Console.WriteLine("\nDescription: " + item3.Description);
Console.WriteLine("Units on hand: " + item3.UnitsOnHand);
Console.WriteLine("Price: $" + item3.Price);
Console.WriteLine("\nDisplay the total inventory.");
Console.WriteLine("The total inventory is " + (item1.UnitsOnHand + item2.UnitsOnHand + item3.UnitsOnHand));
Console.Read(); // to hold the output screen
}
}
}

Output

魟file:///C:/Users/AKSHAY/App Data/Local/Temporary Projects/ConsoleAppli elcome to the Retail store! Price must be greater then e Please enter units on hand for item 1: 33 Inventory must be greater then e Please enter the price for item 1: 10 Please enter the description for item 1: shirt Display all items Description: shirt Units on hand: 10 Price: $33 Description: Jeans Units on hand: 4e Price: $34.95 Description: Long sleeve shirt Units on hand: 20 Price: $24.95 Display the total inventory he total inventory is 7e

Add a comment
Know the answer?
Add Answer to:
Need this program in C#. Thank you 3/19 Lab11 PartC Dur Scenario/Summary Write a windows console...
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
  • 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:...

  • 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...

  • 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...

  • I need help with my homework please. I should write this program in C++ language and...

    I need help with my homework please. I should write this program in C++ language and use Inventory.h file (header file), Inventory.cpp file (implementation file), and main.cpp file (main program). This is the program: Demonstrate the class in a driver program. Input validation, don’t accept negative values for item number, quantity, or cost. 6. Inventory Class Design an Inventory class that can hold information and calculate data for items ma retail store's inventory. The class should have the following private...

  • 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...

  • 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...

  • 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...

  • 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...

  • please write in C++ Write a program that uses a structure to store the following inventory...

    please write in C++ Write a program that uses a structure to store the following inventory data in a file: The data can be either read from a text file or the keyboard Item name (string) Quantity on hand(int) Wholesale cost(double) Retail Cost(double) The program should have a menu that allows the user to perform the following tasks: Add new records to the file Display any record in the file User will provide the name of the item or 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