program #1

Need assistance with this HW assignment. I know my code to output is incorrect

Here is the program requirements...


Practice Exercise #1
Program Input

The input to the program will be the product id number (a 5-digit identification number), the manufacturer's id number (a 4-digit identification number), the wholesale price of the product, the mark-up percentage for the product, the description of the product, and the quantity of product in stock.

The following is an example of this input:

Product ID # 10001
Manufacturer's ID # 5020
Wholesale Price 15.00
Mark-Up % .20
Product Description 3.5" Floppy Disks
Quantity In Stock 140

Output
Prepare a listing of the inventory for the store with appropriate column headings. This listing should include the following:

a. the product id number; integer
b. the product description; character
c. the manufacturer's id number; integer
d. the wholesale price of the product; double
e. the mark-up percentage for the product; double
f. the quantity of product in inventory. integer

The retail price for the product (the wholesale price increased by the mark-up percentage) should be printed as a separate item from the above listing.

Processing
1. The class variables, which represent a single product sold by the store, should include the following data members:

(6 private members)
a. the product id number integer
b. the description of the product character array
c. the manufacturer's id number integer
d. the wholesale price of the product double
e. the mark-up percentage for the product double
f. the quantity of product in inventory integer

2. The class should have the following member functions:

(10 public members)
a. Two constructors. The first is the default, which sets all of the members of the class to zero. The second constructor should enable the user to specify all of the initial attributes of the members of the class.
b. Separate functions which return the values of the members of the class.
c. A function that displays the values of the members of the class to the monitor (as described in the "output" section).
d. A function that returns the class object's retail price (the wholesale price increased by the mark-up percentage).

Below is the code. Any help would be great Thanks!

//Header File or Specification File
//Filename: Inventory.h

#ifndef Inventory_H
#define Inventory_H

#include <iostream>
#include <iomanip>

using namespace std;

class Inventory

{
public :
//**************
//*Constructors*
//**************

Inventory( );
Inventory( int, char [], double );

//******************************************
//* Return the value of the private members*
//******************************************

//*************************************************************************
//* By adding the "const" modifier following a member function declaration*
//* the member function is prevented from modifying any data in the class *
//*************************************************************************

int GetProductId( ) const;
char* GetProductDescription ( ) const;
int GetManufactId ( ) const;
double GetWholesalePrice ( ) const;
double GetMarkup ( ) const;
int Quantity;
//********************************************
//* Display Information Concerning A Inventory*
//********************************************

void Display ( ) const;

private:

int ProductId;
int ManufactId;

//**************************************************************
//* Only class data members can be declared "mutable" *
//* The purpose of "mutable" is to specify which data members *
//* can be modified by const member functions *
//* Normall, a const member function cannot modify data members*
//**************************************************************
mutable char ProductDescription[25];
};

#endif

//Implementation File
//Filename: Inventory.cpp

#include "Inventory.h"

//*******************
//Constructors *
//*******************

Inventory::Inventory( )
{

ProductId = 0;
ProductDescription[25] = "\0";
ManufactId = 0;
WholesalePrice = 0;
Markup = 0;
Quantity = 0;

}

Inventory::Inventory ( int InitProductId, char InitProductDescription[], int InitManufactId, double InitWholesalePrice, double InitMarkup, int InitQuantity )

{
ProductId = InitProductId;
strcpy_s( ProductDescription, InitProductDescription );
ManufactId = InitManufactId;
WholesalePrice = InitWholesalePrice;
Markup = InitMarkup;
Quantity = InitQuantity;



}

//*************************************************
//* Return the value of the private class members *
//*************************************************

int Inventory::GetProductId( ) const
{
return (ProductId);
}

double Inventory::GetManufactId( ) const
{
return( ManufactId );
}

//*********************************************
//* Display information concerning a GoldFish *
//*********************************************
void Inventory::Display() const

{
char Separator[50] = "________________________________________________";

//*******************************************
//* Display header for Inventory information *
//*******************************************

cout << endl << Separator << endl << endl;
cout << setw(36) <<setfill(' ') <<"Office Supply Product Information" << endl;
cout << Separator;
cout << endl << endl << setw(15) << setfill(' ') << "Identification"
<< setw(12) <<setfill(' ') <<"Type of"
<< setw(17) <<setfill(' ') <<"Price" << endl
<< setw(11) <<setfill(' ') <<"Number"
<< setw(17) <<setfill(' ') <<"GoldFish"
<<endl << Separator << endl << Separator <<endl;

//*****************************
//* Display data for Inventory *
//*****************************
cout << right;
cout << endl << setw(9) << setfill (' ') << GetProductId ( );
cout << fixed << showpoint << setprecision(2)
<< setw(12) << setfill(' ')
<< " $ " << GetManufactId()
<<endl;
cout << Separator << endl;
}

//Client Code File
//Filename: InventoryClientCode.cpp

#include "Inventory.h"

int main()
{
int InitProductId = 0;
char InitProductDescription[25] = "\0";
int InitManufactId = 0;
double InitWholesalePrice = 0;
double InitMarkup = 0;
int InitQuantity = 0;

char NextChar= '\0';
char ContinuationFlag = 'Y';

//*****************************************************
//* The "ContinuationFlag" is a control variable used *
//* in creating a loop. The loop mechanism that is *
//* employed is a "do while" where the flag is checked*
//* at the end of the loop *
//*****************************************************

//*******************************************
//* The "toupper" function returns the upper*
//*case valie of the argument passed *
//*******************************************

while (toupper(ContinuationFlag) == 'Y')
{

cout << endl;
cout << "Enter the Product's Identification Number: "<< endl;
cin >> InitProductId;
cout << "Enter The Type of Product Description: : " << endl;
cin >> InitProductDescription;
cout << "Enter the Manufacturer's Identification Number: "<< endl;
cin >> InitManufactId;
cout << "Enter the Wholesale Price: "<< endl;
cin >> InitWholesalePrice;
cout << "Enter the Mark-up Percentage: "<< endl;
cin >> InitMarkup;
cout << "Enter the Quantity of the Product in Stock : "<< endl;
cin >> InitQuantity;

//*The "peek" function returns the next character *
//*without extracting it from the input stream

NextChar = cin.peek();

//********************************************************
//* If the next character is a "\n" (the carriage *
//* return character). then the "ignore" function *
//* is called. The "ignore" function, without input *
//*agrument, will cause the next character to be skipped *
//********************************************************



//**************************
//* Create Inventory Object *
//**************************

Inventory InventoryItem ( InitProductId, InitProductDescription, InitManufactId, InitWholesalePrice, InitMarkup, InitQuantity );

//*******************************************
//* Display Information Concerning Inventory *
//*******************************************

InventoryItem.Display( );

cout << endl
<< "Do you wish to enter any more Products?"
<< endl;
cout << "Enter 'Y' or 'N'" << endl;

cin >> ContinuationFlag;
}

return 0;

}




Topic archived. No new replies allowed.