Question

Object Oriented Programming using class c++ Program where the users (customers) can add Product name, Product...

Object Oriented Programming using class c++

Program where the users (customers) can add Product name, Product Price, Product Quantity.

Program needs a menu: 1. Add item 2. Get total 3. Display all items

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

The following c++ program store Product Name, Product Price, Product Quantity in 3 arrays.

Program:

#include <iostream>

using namespace std;
void addItem();
void getTotal();
void display();
string Pname[50];
int pPrice[50];
int pQuantity[50];
int i=0;

int main(void)

{

char selection;


while(selection != 4){
cout<<"\n Menu";

cout<<"\n========";

cout<<"\n 1. Add item";

cout<<"\n 2. Get total";

cout<<"\n 3. Display all items";

cout<<"\n 4 - Exit";

cout<<"\n Enter selection: ";

// read the input

cin>>selection;


switch(selection)

{

case '1' : addItem();

break;

case '2' : getTotal();

break;

case '3' : display();

break;

case '4' :{cout<<"\n To exit the menu";}

break;

// other than 1, 2, 3 and 4...

default : cout<<"\n Invalid selection";

// no break in the default case

}
}

cout<<"\n";

return 0;

}
void addItem(){
cout<<"\n Enter Product name, Product Price, Product Quantity";
cin>>Pname[i];
cin>>pPrice[i];
cin>>pQuantity[i];
i++;
}
void getTotal(){
cout<<i;
}
void display(){
for(int j = 0; j<i; j++){
cout<<Pname[j];

cout<<"\n";
}
}
Screenshot:

Add a comment
Know the answer?
Add Answer to:
Object Oriented Programming using class c++ Program where the users (customers) can add Product name, Product...
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
  • Object Oriented Programming C++ using class I need users (customers) to input their name and id....

    Object Oriented Programming C++ using class I need users (customers) to input their name and id. Program needs to have a menu: 1. Create - input id, name 2. List - see all the list of the users 3. Exit. It should be limited to 20 users only.

  • Please implement the following only using Javascript. design a cash register class that can be used...

    Please implement the following only using Javascript. design a cash register class that can be used with inventory item class. The cash register class needs to: 1. ask user for item and quantity being purchased. 2. get the items cost from inventory item object 3. add 30% profit to the cost to get the items unit price 4. multiply the unit price times the quantity being purchased to get purchase subtotal 5. compute a 6% sales tax on the subtotal...

  • BMI Class. Using JAVA write Object Oriented Programming by creating class, object and method , that...

    BMI Class. Using JAVA write Object Oriented Programming by creating class, object and method , that takes users' input (weight and Height) and calculates the BMI. If the result is less than 18.5 display "you are underweight", if the result is greater than 18.5 display "you have a normal weight", if the result is greater than 24.9 display "your weight is considered overweight", and the result is greater than 30 display "your weight is considered as obese" (BMI = 703...

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

  • Write a python program using Object Oriented and do the following: 1. create class "cat" with...

    Write a python program using Object Oriented and do the following: 1. create class "cat" with the following properties: name, age (create constructor method: def __init__) 2. create class "adopter" with the following properties: name, phone 3. create class "transaction" with these properties: adopter, cat (above objects) cat1 = "puffy, 2" adopter1 = "Joe, 123" Test your program: Joe adopts puffy. Print: "Per Transaction 1 <joe> has adopted <puffy>" this can only be done with object oriented programming, no way...

  • Project Lists and Object-oriented Programming Note: using c++ This project is an individual assignment that focuses...

    Project Lists and Object-oriented Programming Note: using c++ This project is an individual assignment that focuses on object-oriented programming and lists. The list will be a doubly-linked list and it will be implemented using nodes and pointers. The data contained in the list will be objects from a class. Project data: You will choose one of the following classes to define: Boat, Earthquake, Game, Sport, State, Website, House, Phone, Activist, Plant, Fish, Parrot, and Course. Your class code will include...

  • 1) Using the Object-Oriented Programming Paradigm,implement the necessary code in Python creating a ‘Car’ class with...

    1) Using the Object-Oriented Programming Paradigm,implement the necessary code in Python creating a ‘Car’ class with a constructor that stores all the Car information (ID, MAKE, MODEL, YEAR , COLOR, MILEAGE, PRICE_TO_DEALER, SALE_PRICE, PROFIT) as attributes. 2) Implement and add the following methods to the ‘Car' class in Question 1. a) necessary getter methods b) necessary setter methods c) method to display all the information to the screen d) a method to calculate the profit

  • C++ ONLY This is your first ever program using object oriented methodology. In this assignment you...

    C++ ONLY This is your first ever program using object oriented methodology. In this assignment you will need to instantiate (create) object(s) and invoke their member functions to perform different tasks. The program is to keep track of customer orders and to create reports as needed. At minimum you will need several objects to be instantiated throughout the program such as: An OrderProcessor object Order objects (stored in an array) Let’s get to class design now. Class Design class Order:...

  • I was looking for help with a computer science c programming class. not c++ This program...

    I was looking for help with a computer science c programming class. not c++ This program will have menu system. The menu will at least have the following options:                         ***********************************************************                         **                   MAIN MENU **                         *********************************************************** Enter Votes from a state for Donald Trump Choose State Enter Number of Votes Enter Votes from a state for Joe Biden Choose State Enter Number of Votes Display total votes for each candidate List the state name(s) where candidate tied For...

  • Write an object-oriented C++ program (i.e. a class and a main function to use it), using...

    Write an object-oriented C++ program (i.e. a class and a main function to use it), using pointer variables, that program that performs specific searching and sorting exercises of an array of integers. This program has six required outputs. Start by initializing an array with the following integers, in this order: 23, 17, 5, 90, 12, 44, 38, 84, 77, 3, 66, 55, 1, 19, 37, 88, 8, 97, 25, 50, 75, 61, and 49. Your array input may be hardcoded...

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