GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 05-Aug-2008, 16:31
soccer03 soccer03 is offline
New Member
 
Join Date: Aug 2008
Posts: 1
soccer03 is on a distinguished road

Create a program that uses no global variables


Hello! So I'm new to C++, and programming all together. I'm going to school to become a civil engineer and the curriculum says I have to take a C++ class. This is all very confusing to me. I have been able to complete most all of my other assignments without any help but this one has thrown me for a loop.

I'm trying to create a program that uses no global variables and a structure to store the following inventory data in a file:
Item description, quantity on hand, wholesale cost, retail cost, and date added to inventory.

In all actuality I want the program to have a menu that allows the user to add, display and change any record in the file. To make this program sensible it shouldn't accept any cost less than 0. It should also not accept any unreassonable dates. My teacher wants us to include a prodld integer field and ensure that it is in therange of 1-15. The prodId field should the record number within the file. For example, the product with the prodid value of 2 will be the second record in the file, the product with the prodId value of 5 will be the 5th record in the file.

Help would be VERY much apprecaited, as I don't even know where to begin.
  #2  
Old 06-Aug-2008, 01:57
ocicat ocicat is offline
Regular Member
 
Join Date: May 2008
Posts: 580
ocicat is a jewel in the roughocicat is a jewel in the rough

Re: Create a program that uses no global variables


Quote:
Originally Posted by soccer03
I'm trying to create a program that uses no global variables and a structure to store the following inventory data in a file:
Item description, quantity on hand, wholesale cost, retail cost, and date added to inventory.
...which means that any data structures created will have to be passed about as a function parameter -- more precisely, it makes more sense pass data structures by address or reference especially if a function modifies its value in any way.
Quote:
In all actuality I want the program to have a menu that allows the user to add, display and change any record in the file.
Is this a requirement of the assignment? Are all records to be read interactively? The point is not to make your work any more complicated than the requirements mandate.
Quote:
To make this program sensible it shouldn't accept any cost less than 0. It should also not accept any unreassonable dates. My teacher wants us to include a prodld integer field and ensure that it is in therange of 1-15. The prodId field should the record number within the file.
So it sounds like you will will want to enter a value followed by doing some range checking. One idea would be to put entry into a while loop which only exits if the above criteria has been met.
Quote:
For example, the product with the prodid value of 2 will be the second record in the file, the product with the prodId value of 5 will be the 5th record in the file.
One thing you will need to clarify with your instructor is whether he/she expects you to code the random access into the file yourself, or whether you want to maintain all records in memory. Obviously if you do the latter, your application will have an upper limit on how many records can be retained in memory. Random access into the file solves this problem, but can be a bit thorny for newcomers.
 
 

Recent GIDBlogAccepted for Ph.D. program by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Any help would be appreciated ELHEK Java Forum 11 28-May-2006 07:13
C++ Calculator Problem. Any help much appreciated. SpinDizzy C Programming Language 13 12-Jul-2005 14:35
probably a stupid mistake....lil help appreciated wbsquared03 C++ Forum 9 06-Dec-2004 16:43
Need help with a program if anyone can help it would be appreciated Krc784 C++ Forum 1 03-Nov-2004 21:55
Minor Problem with my program. Any help greatly appreciated. agentxx04 C Programming Language 6 24-Oct-2004 16:04

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:09.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.