Google Answers Logo
View Question
 
Q: BASIC C++ PROGRAM INVOLVING A TRIVIAL DATABASE ( Answered,   0 Comments )
Question  
Subject: BASIC C++ PROGRAM INVOLVING A TRIVIAL DATABASE
Category: Computers > Programming
Asked by: cpuprogger-ga
List Price: $70.00
Posted: 12 Mar 2003 20:23 PST
Expires: 11 Apr 2003 21:23 PDT
Question ID: 175461
ok, i do need this program by march 16th at the LATEST, and i will pay
extra if it is here by the 14th of the 15th.
First and foremsot, the end result of this program is completely
irrelecant because the only thing that needs to be done is the
following:

you show good understanding and use all of the following things

arrays or records or objects 
selection constructs (branching) 
iteration constructs (looping) 
subprograms (both built-in and user-defined) 
parameter passing 
sorting techniques or searching techniques 
files 

With that said, the program is basically a database where a user can
enter items into the database, delete items from it, edit the values
and quantities of the item and have a trivial generated order form. 
And the items in the database need to be sorted in the simpiliest of
manner.  I have provided a flow chart.  good luck.  link below for
flowchart, just follow this and you'll be set.  And a password
function to use the program would be kewl, but not nesacary

www.wcryder.addr.com/flowchart4dossier.doc

ps  i cant stress how much time is of the essence at this point, the
sooner the better.  Thats is why i am offering this at such a high
price, i need BASIC coding on an amateur level, the higher price is to
compensate for the lil time, not becuase i want detail.  I only ask
for a simple program meeting the above requirements and has inline
docuentation

Request for Question Clarification by studboy-ga on 12 Mar 2003 23:53 PST
What's your compiler?  gcc?  Visual C++?

Request for Question Clarification by studboy-ga on 13 Mar 2003 00:02 PST
If you don't care about the compiler then I'm going to assume a compiler...

Clarification of Question by cpuprogger-ga on 13 Mar 2003 06:52 PST
i use G++ as my compiler.  And please use iostream.h,  not the ehader
file for standard input and output if that makes sense.... basicaly i
want cin and cout statements, not printf statements.  And please
somment the code so i can follow along.  THANKS!

Request for Question Clarification by googleexpert-ga on 13 Mar 2003 13:19 PST
What format should the Database be in "flat text file" or something
like an "Access Database"?

Clarification of Question by cpuprogger-ga on 13 Mar 2003 14:52 PST
honestly, it doesnt matter to me, so do what ever is easiest b/c this
is supposeed to be a basic program.  Just make sure the file for the
database saves each time and demonstrates a mastery of files.  Thanks
Answer  
Subject: Re: BASIC C++ PROGRAM INVOLVING A TRIVIAL DATABASE
Answered By: studboy-ga on 13 Mar 2003 21:44 PST
 
Hi cpuprogger-ga:

(BTW, Since I get this done by the *13th*, do I deserve a *bigger* bonus? 
How about doubling the price?  Just kidding :) Please use "tipping" method
for the bonus.  Thanks!).

Here are the source files--

http://www.csua.berkeley.edu/~pchen/database.zip

1) unzip
2) make (or gmake)

The executable created is: database

database.txt is the database file (text).

To understand this, just look at

main.c
databaselib.c

The rest are just supporting files/libraries to enable cleaner abstraction
(also demonstrate mastery of encapsulation).

All files are well commented and should be self-explanable.
File IO mastery is demonstrated by doing it two ways:
the convention string way (in ReadFile) and the stream way (in WriteFile).


Here's a script of the run:


> database
Welcome to the Studboy's Database Demo!  Please enter username and password.
Username: studboy
Password: what???
Your password is INVALID!!! The right password is GoogleAnswers
> database
Welcome to the Studboy's Database Demo!  Please enter username and password.
Username: studboy
Password: GoogleAnswers
Your password is valid!

Welcome!  This program lets you manage items.
You may add and remove items as well as place orders.

Reading in database...
done reading!


Welcome studboy.  Please select from menu:
1. Add item.
2. Remove item.
3. View/edit items.
4. Place order.
5. Quit.
Enter your selection: Please enter an integer
: 1

MENU:
1. Add new item.
2. Main menu.
Enter your selection: 1

Enter the name of the item to add: Sex
Enter an initial inventory count: 3

MENU:
1. Add new item.
2. Main menu.
Enter your selection: 1

Enter the name of the item to add: Booz
Enter an initial inventory count: 5

MENU:
1. Add new item.
2. Main menu.
Enter your selection: 2


Welcome studboy.  Please select from menu:
1. Add item.
2. Remove item.
3. View/edit items.
4. Place order.
5. Quit.
Enter your selection: 3

MENU:
1. View items.
2. Edit items.
3. Main menu.
Enter your selection: 1

Items in database
-------------------
1) BOOZ 5
2) SEX 3

MENU:
1. View items.
2. Edit items.
3. Main menu.
Enter your selection: 2

Items in database
-------------------
1) BOOZ 5
2) SEX 3
Enter the item number of the item you want to edit: 2
Enter new inventory count: 8

MENU:
1. View items.
2. Edit items.
3. Main menu.
Enter your selection: 1

Items in database
-------------------
1) BOOZ 5
2) SEX 8

MENU:
1. View items.
2. Edit items.
3. Main menu.
Enter your selection: 3


Welcome studboy.  Please select from menu:
1. Add item.
2. Remove item.
3. View/edit items.
4. Place order.
5. Quit.
Enter your selection: 4

MENU:
1. Order item.
2. Main menu.
Enter your selection: 1

Items in database
-------------------
1) BOOZ 5
2) SEX 8
Enter the item number of the item you want to order: 1
Enter how many: 4
Your order for 4 BOOZ has been sent to the appropriate dept!

MENU:
1. Order item.
2. Main menu.
Enter your selection: 2


Welcome studboy.  Please select from menu:
1. Add item.
2. Remove item.
3. View/edit items.
4. Place order.
5. Quit.
Enter your selection: 5
>
> cat database.txt
BOOZ
5
SEX
8
> database
Welcome to the Studboy's Database Demo!  Please enter username and password.
Username: studboy
Password: GoogleAnswers
Your password is valid!

Welcome!  This program lets you manage items.
You may add and remove items as well as place orders.

Reading in database...
done reading!


Welcome studboy.  Please select from menu:
1. Add item.
2. Remove item.
3. View/edit items.
4. Place order.
5. Quit.
Enter your selection: Please enter an integer
: 3

MENU:
1. View items.
2. Edit items.
3. Main menu.
Enter your selection: 1

Items in database
-------------------
1) BOOZ 5
2) SEX 8

MENU:
1. View items.
2. Edit items.
3. Main menu.
Enter your selection: 3


Welcome studboy.  Please select from menu:
1. Add item.
2. Remove item.
3. View/edit items.
4. Place order.
5. Quit.
Enter your selection: 2

MENU:
1. Remove item.
2. Main menu.
Enter your selection: 1

Items in database
-------------------
1) BOOZ 5
2) SEX 8

Enter the item number of the item to remove: 2
SEX removed from the database.
MENU:
1. Remove item.
2. Main menu.
Enter your selection: 2


Welcome studboy.  Please select from menu:
1. Add item.
2. Remove item.
3. View/edit items.
4. Place order.
5. Quit.
Enter your selection: 3

MENU:
1. View items.
2. Edit items.
3. Main menu.
Enter your selection: 1

Items in database
-------------------
1) BOOZ 5

MENU:
1. View items.
2. Edit items.
3. Main menu.
Enter your selection: 3


Welcome studboy.  Please select from menu:
1. Add item.
2. Remove item.
3. View/edit items.
4. Place order.
5. Quit.
Enter your selection: 5
> cat database.txt
BOOZ
5
>

Request for Answer Clarification by cpuprogger-ga on 13 Mar 2003 22:30 PST
i need a lil clarifcation here.  Basicaly, your too good at this. 
This program is for a entry level 2 semester c++ course.  The program
is just a lil too advacned for me.  Not nesacarily the code itself,
but the multiple files utilized.  Is it possible to make this program
lets say 3 or less files instead of the 16 you sent me. Thanks and i
appreciate the quickness of your answer

Request for Answer Clarification by cpuprogger-ga on 13 Mar 2003 22:53 PST
ok,, i just got done reading the code.  i have a few requests:
this is WAY to advanced for me.  

1. Do not include static variables
2. Making every output statement a regualr cout statement, with a
"std::" ibn front
3. Dont include the library files, they are already loaded on my
system and complicate.  Only include those you either edited or write
4.  Change file extension from "c" to "cpp" unless there is a reason
the files are ".c" and not ".cpp"
5.  Do not use simpio is a library i never heard of, i only need c++
libraries.  Please use conio library
6.  I dont needa  garbage collecting allocator... a little beyond my
level

To break it down, i want it simple.  I only want the files you wrote
or edited, not the standard included files.  And please clarify why C
library files are being used and not c++ library files.  THis is a c++
program and i am a lil confused.  The only three files that looked
useful to me were databaselib.c databaselib.h and main.c which again,
needs to be .c++  So please just bring the level of programming down a
few notches.  This is a first year beginners course.  thanks a lot!!!
i appreciate your flexibility and speed very much.  Basically i have
to turn this in, and one look at it and my teacher is just gonna be
like, uhhh i havent taught u half of this.  thanks again and i hope
all of this made sense.

Clarification of Answer by studboy-ga on 13 Mar 2003 23:32 PST
Hi cpuprogger-ga


This *is* simple.  C++ is essentially an extension of C--
so to demonstrate mastery, in my opinion, means to do it
in both ways, as demonstrated by the program.  G++ compiles
it fine, can't it?  It means some C is part of C++.
First a few things:

1) You didn't originally specify the restrictions as you've pointed out here.
2) To get rid of of std::, do use namespace std.  Using std::
is not a problem IMO.
3) simpio is just a collection of basic IO routines I used regularly--
a quick look at it and you'll see that parts of it can be taken out
easily.  Garbage collection is good practice in general--
again, this is basic stuff, nothign complicated.

Lastly, you didn't tell me this is for a class--if it is,
I'd recommend you *do not* use this service--Google Answers
is *searchable* by all means--your instructor WILL see this
answer--believe me, it happened to my clients before.

Let me know what you think.  I can simplify the libraries for you.
Again, C++ is an extension of C.  This stuff is as basic as it gets.

Clarification of Answer by studboy-ga on 13 Mar 2003 23:35 PST
Hi cpuprogger-ga

Also regarding the file names, you can go ahead
and rename them cpp.  They work the same both ways.

Clarification of Answer by studboy-ga on 13 Mar 2003 23:38 PST
Also, the library files *are* my own files--they are not std library
files on your system.

Request for Answer Clarification by cpuprogger-ga on 14 Mar 2003 00:26 PST
ok, in that cases please anyway rename the files for me and please get
rid of the std:: before all the cout statements.  And most
importantly, make the code a little more simplier and on a more basic
level.  I understand the garbage collection is basic, but it is an
operation we did not cover in class so please remove it.  And try to
minimize the number of files being used.  thanks again, you have been
a great help

Clarification of Answer by studboy-ga on 14 Mar 2003 00:33 PST
Hi cpuprogger-ga:

OK, I got an idea that might work for you--
as an exercise, take main.c, databaselib.c/h
and see if you can rewrite some of the functions
inside it yourself.  This will not not only help you
but also help you stake a claim to
your instructor that this is your original work.
It should not be that difficult--take a look at the
other files I provided to get some ideas.

Clarification of Answer by studboy-ga on 14 Mar 2003 00:35 PST
I got your post right after I post.  Sorry.  OK, I will see what I can
do in the morning.  Stay tuned.

Clarification of Answer by studboy-ga on 14 Mar 2003 00:45 PST
Also, can you send me a link to your class?  Certain instructors/TAs
have preferences for certain "styles".  I can get a pretty good feel
for what he/she likes by the samples he/she posts in his/her lecture
notes.  I can incorporate this into the code to help you get an A.

Clarification of Answer by studboy-ga on 14 Mar 2003 02:13 PST
OK, I've uploaded a new version:

1) Rename .c to .cpp
2) std::cout -> cout
3) Take away garbage collection
4) Simplify and reduce number of files

http://www.csua.berkeley.edu/~pchen/database.zip 

Please inform me as soon as you've downloaded it--
I'll try to protect you by disabling the link afterwards.

Request for Answer Clarification by cpuprogger-ga on 14 Mar 2003 07:41 PST
ok i downloaded the file, still a il unclear

1st of a all i should have been a lil mpre clear on what this is for -
 it's an ap high school class hence the stress on simplicity.  It's
out first year programming.  And second, i thought there were going to
be a less number of files, now i see 23 files instead of 16.  Did you
personally author everyone of the files?  Or are some built in header
files you just copied and pasted?  Id like to only turn things in that
are persnoally author.  You've been a great help and i appreciate the
clarification here.  As per style, i will take care of that, but
thanks for offereing.  She is kinda specific so its hard to explain.

Clarification of Answer by studboy-ga on 14 Mar 2003 08:06 PST
Hi cpuprogger-ga,

There are only 7 .cpp files, but you count 23?
Please double check the .zip file.
Did you count the compiled files and the .o files?

Yes, these I authored.  Of course they are based on my
previous work and works I've done/taken in/from classes--programming 
is essentially an art of reusing what you learned in the past.

Here's what I suggest: look through the codes carefully, and 
take the time to rewrite the 5-6 functions inside databaselib.cpp.
The flow is already there--you just need to spend about 1-2 hours
on it.  This will help you understand the problem as well as,
well, pass the AP test later :)

Clarification of Answer by studboy-ga on 14 Mar 2003 08:28 PST
For example, let's take a function--GetInteger()

1) *Think* about what it's doing--it's trying to get an integer from the user.
2) Think about how to rewrite it, well, how about this:

integer in;
cin >> in;
return in;

etc, and etc.
Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy