) Convert your structure into a class. For this exercise, you can leave the data as public (otherwise you would have to change the input and output functions). 2) Write a member function show_all that prints all the information for one record - name, cost, markup, and the three inventory numbers. 3) Add a user option S that lets the user see all the information for all the items in the inventory, using the show_all member function. Print a header so the user knows what each column means, and format the output to appear in columns. Hint: do a setwidth() before *each* cout. Pick widths that make sense for name, cost, markup, and the three inventory numbers.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter13: Overloading And Templates
Section: Chapter Questions
Problem 15SA
icon
Related questions
Question

 

In C++
 
1) Convert your structure into a class. For this exercise, you can leave the data as public (otherwise you would have to change the input and output functions).
2) Write a member function show_all that prints all the information for one record - name, cost, markup, and the three inventory numbers.
3) Add a user option S that lets the user see all the information for all the items in the inventory, using the show_all member function.
Print a header so the user knows what each column means, and format the output to appear in columns.
Hint: do a setwidth() before *each* cout. Pick widths that make sense for name, cost, markup, and the three inventory numbers.

 

 

 

 

Previous Code:

#include <iostream>
using namespace std;
// function to prompt for the re-assigning 
int placement(int REDApplesCounter, int REDApplesCounterOnShelf, int AssortedBouquetsCounter, int CamembertCheeseCounter)
{
    // prompt for values
    cout<<"Enter the values in (P)lacement \n "<<endl;
    cout<<"Items Exists are: Red Delicious Apples, Assorted bouquets, Camembert Cheese"<<endl;
    cout<<"Enter the Red Apples Count: "; cin>>REDApplesCounter;
    cout<<"Enter the Red Apples on shelf Count: "; cin>>REDApplesCounterOnShelf;
    cout<<"Enter the Assorted bouquets Count: "; cin>>AssortedBouquetsCounter;
    cout<<"Enter the Camembert Cheese Count: "; cin>>CamembertCheeseCounter;
    return (REDApplesCounter, REDApplesCounterOnShelf, AssortedBouquetsCounter, CamembertCheeseCounter);
}

// main function
int main()
{
    // prompt for the values
    cout<<"Enter values "<<endl;
    int REDApplesCounter, REDApplesCounterOnShelf, AssortedBouquetsCounter, CamembertCheeseCounter;
    cout<<"Items Exists are: Red Delicious Apples, Assorted bouquets, Camembert Cheese"<<endl;
    cout<<"Enter the Red Apples Count: "; cin>>REDApplesCounter;
    cout<<"Enter the Red Apples on shelf Count: "; cin>>REDApplesCounterOnShelf;
    cout<<"Enter the Assorted bouquets Count: "; cin>>AssortedBouquetsCounter;
    cout<<"Enter the Camembert Cheese Count: "; cin>>CamembertCheeseCounter;
    
    
    cout<<"\n***********************************"<<endl;
    // prompt for choice
    char choice;
    cout<<"You have 3 \n(P)lacement\t(W)arning\te(X)it: ";cin>>choice;    
    
    // defining the switch cases
    switch(choice)
    {
        // for Placement
        case 'P': 
        {
            cout<<endl;
            cout<<"\nThe Red Apples Counts are: "<<REDApplesCounter;
            cout<<"\nThe Red Apples on shelf Counts are: "<<REDApplesCounterOnShelf;
            cout<<"\nThe Assorted bouquets Counts are: "<<AssortedBouquetsCounter;
            cout<<"\nThe Camembert Cheese Counts are: "<<CamembertCheeseCounter;
            cout<<"\nIf you want replacement then enter 'Y' otherwise 'N': ";
            bool ch;
            cin>>ch;
            // if user wants to again assign the values
            if(ch=='Y')
            {
                placement(REDApplesCounter, REDApplesCounterOnShelf, AssortedBouquetsCounter, CamembertCheeseCounter);
            }
            break;
        }
        
        // For warnings
        case 'W': 
        {
            cout<<endl;
            if(REDApplesCounter<10)
                cout<<"Warning: Red delicious Apples counter: "<<REDApplesCounter<<endl;
            if(REDApplesCounterOnShelf<10)
                cout<<"Warning: Red delicious Apples shelf: "<<REDApplesCounterOnShelf<<endl;
            if(AssortedBouquetsCounter<10)
                cout<<"Warning: Assorted bouquets warehouse: "<< AssortedBouquetsCounter<<endl;
            if(CamembertCheeseCounter<10)
                cout<<"Warning: Camembert Cheese warehouse: "<< CamembertCheeseCounter<<endl;
            break;
        }
        
        // Exit from the program
        case 'X':
            exit(0);        
            
        default: 
            cout<<"Wrong Input: "<<endl;
   }
   return 0;

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr