Maximum PC

It is currently Mon May 04, 2015 12:12 pm

All times are UTC - 8 hours

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Help with C++ Program
PostPosted: Sat Nov 20, 2004 2:24 pm 

Joined: Fri Oct 29, 2004 11:59 am
Posts: 2
Hey everyone,
I am having alot of trouble trying to fiqure out what is wrong with the program. I have posted the assignment and what I have completed so far. If anyone thinks they can help please let me know ASAP! thanks!

Inventory Reporting Program
Due: Monday, November 22 2004
75 Points

Design and write a program that reads the contents of an inventory file into a structure array. Present a menu of reporting choices to a user as described in the sample menu below. Also include a choice that allows the user to change the value of any product quantity.

Read the contents of the inventory file into an inventory structure array. You can assume that there will be a maximum of 200 products. Therefore, the inventory array should be declared to hold a maximum of 200 products. Fill the inventory array by reading the contents of the file named Product number (4 digit) Product description (35 characters) Product quantity (6 digit)

Present a menu to the user:

Welcome to the Inventory Reporting System.
Select an activity from the menu:

1) Update inventory quantity for a product
2) Report product with highest quantity in inventory
3) Report product with lowest quantity in inventory
4) Report average inventory quantity level for all products
5) Exit the program

Enter Choice (1 - 5):

Use a switch statement to manage the menu. The user should be given an error message, then re-prompted with the menu if an invalid choice is entered.
Each case in the switch statement should call a function that performs the work described by the choice selected.

When the inventory file is read into the array, you can use the product code values as unique product codes for searching. A sample dialog for choice 1 might look like this:

Enter the product code to update: 777

Product description for product 777:
Terrible Towels - Gold and Black

The current quantity for product #777 is 241 units.

Enter the new value: 240

The new quantity for product # 777 is 240 units.

Your program must report an error to the user if the user attempts to enter a product number for a non-existent product.

Your program may not use global variables. At least 4 functions are required (main, an input function, a processing function, and an output function). You must pass the array to the appropriate functions as a parameter.

WHAT TO TURN IN (stapled together):

Printed algorithm.
Print out of program source code.
Print out of dialog for menu choice 1 using 75 as the new quantity value.
Print out of dialog for menu choice 4.


# include <iostream>
# include <fstream>
using namespace std;

const int Max_Record=200;
ifstream infile;
ofstream outfile;

struct inventoryRecord
int productNum;
char productDesc[20];
int productQty;

void update(inventoryRecord[]);
int highQty(inventoryRecord[],int);
int lowQty(inventoryRecord[],int);
void avgQty(inventoryRecord[],int);
int getdata(inventoryRecord[]);
void outdata(inventoryRecord[],int);

int main (void)
infile.open("C:\\Documents and Settings\\Owner\\My Documents\\Class Documents\\C++\\inventory2.doc");
outfile.open("C:\\Documents and Settings\\Owner\\My Documents\\Class Documents\\C++\\inventory2.doc");
inventoryRecord array[Max_Record];
char choice;
int highest;
int lowest;
int size=getdata(array);

cin>> choice;

switch (choice)

case 1:
case 2:
case 3:
case 4:
avgQty(array, size);
cout<<"You have entered an incorrect option.";



void update(inventoryRecord array[Max_Record])
int prodUpNum;
int newQty;

cout<< "Enter the product code to update:";
cin>> prodUpNum;
for(int index=0; !infile.eof(); index++)
cout<< "What is the new quantity of this Product?";
cin>> newQty;
array[index].productQty=newQty ;



int highQty(inventoryRecord array[Max_Record],int size)
int highest=0;

for (int index=0; index<size; size++)
if (array[index].productQty>highest)

return highest;

int lowQty(inventoryRecord array[Max_Record],int size)
int highest;
int index=0;
int lowest=array[index].productQty;

for (;index<size; size++)
if (array[index].productQty<lowest)
return lowest;

void avgQty(inventoryRecord array[Max_Record],int size)
int total=0;
float average=0;
for (int index=0; index<size; index++)

cout<< "The average Qty is "<<average<<" .";

int getdata(inventoryRecord array[Max_Record])
int index=0;
int size=0;

return size;

void outdata(inventoryRecord array[Max_Record],int size)
int index=0;


 Post subject:
PostPosted: Sat Nov 20, 2004 6:44 pm 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
Please edit your post using the code bbcode tags. Also, what is the program doing incorrectly? What should it be doing instead?

import java.util.*;

public class MyClass {

    public static void main(String[] args) {


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours

Who is online

Users browsing this forum: No registered users and 4 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

© 2014 Future US, Inc. All rights reserved.