Project Help


 
Thread Tools Search this Thread
Top Forums Programming Project Help
# 1  
Old 12-17-2005
Project Help

hi all.

Im not sure whether this is the correct forum to post in, but here goes.

I've been given my first year (uni) project c++, a pretty small one really. Problem is I have written a code, but I havent tested or debugged it (dont ask). Can someone check it and correct any errors I have made, and suggest anyways i can improve it further. Thanks in advanced. Smilie

ps. Im not sure whether my program is actually doing the things the scenario wants me to do. I dont know whether Im on the right track so I have attached the scenario to this post, and if anyone could read the scenario and see if my code is the correct way forward etc.. Thanks.



#include <iostream>
#include <assert>
#include <fstream>
using namespace std ;
const int BOOKS_MAX = 5000

// OPEN/READ/PROCESS BOOKDATA FILE FUCTION
void openfile (int argc, char* argv[])
{
assert (argc >= 2) ;
ifstream accfile(argv[1]);
if ( !accfile )
{
cerr << "File " << argv[1] << " not found\n" ;
exit(1) ;
}
int books = 0;
books a ;
accfile >> a.name >> a.booktitle >> a.booktype >> a.ID >> a.Taken ;
account accs[BOOKS_MAX] ;
int read = 0
//Read data file
do
{
accfile >> accs[read].name
>> accs[read].booktitle
>> accs[read].booktype
>> accs[read].ID ;
>> accs[read].Taken
if (accfile)
{
read++ ;
}
} while (accfile && read < BOOKS_MAX) ;
cout << read << " Books read\n " ;
accfile.close() ;
// Begin proccess
for (int i = 0; i < read; i++)
{
if (accs[i].booktitle == input && accs[i].Taken = 0
{
cout << accs.booktitle << "This book is currently unavailable " ;
exit (0) ;
}
else
{
cout << accs[i].booktitle << "This book is Available " ;
}
}
cout << "To loan this book please press 1, otherwise, to exit press 9\n " ;
int issue = 0 ;
cin >> issue ;
if (issue == 1)
{
ofstream oaccfile( argv[1] ) ;
for (int i = 0; i < read; i++)
{
oaccfile << accs[i].taken = 0 << endl ;
}
oaccfile.close();
}
else
{
if (issue == 9)
{
exit(0);
}
}

// OPEN USERDATA FILE FUNCTION
void user (int argc, char* argv[])
{
assert (argc >= 2) ;
ifstream accfile(argv[1]);
if ( !accfile )
{
cerr << "File " << argv[1] << " not found\n" ;
exit(1) ;
}
int accounts = 0 ;
accounts a;
accfile >> a.name >> a.street >> a.ID >> a.Bookstaken ;
int USER = 1000 ;
account accs[USER] ;
int readn = 0 ;
//Read data file
do
{
accfile >> accs[readn].name
>> accs[readn].street
>> accs[readn].ID
>> accs[readn].Bookstaken ;
if (accfile)
{
readn++ ;
}
} while (accfile && read < USER) ;
cout << readn << " acccounts read\n " ;
accfile.close() ;


// Input
int main()
{
cout << "Welcome\n " << "Please choose from one of the following options\n " << "To Search for a book press 1\n To Return a book press 2\n To exit Press 3 "
int a = 0 ;
cin >> a ;
if (cin == 0)
{
exit(0);
}
else {
if (cin = 1)
{
cout << "Please enter a book title " ;
cin >> input ;
openfile (input) ;
exit(0) ;
}
else (
if (cin = 2)
{
//WRITE CODE HERE FOR BOOK RETURN
}
}
# 2  
Old 12-17-2005
Please make sure that you have read our rules. And note:
(6) Do not post classroom or homework problems.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

FINDING DUPLICATE PROJECT ( directory project )

I have a project tree like that. after running find command with the -no -empty option, i am able to have a list of non empty directory DO_MY_SEARCH="find . -type d -not -empty -print0" MY_EXCLUDE_DIR1=" -e NOT_IN_USE -e RTMAP -e NOT_USEFULL " echo " " > $MY_TEMP_RESULT_1 while... (2 Replies)
Discussion started by: jcdole
2 Replies

2. News, Links, Events and Announcements

A new project was posted on The UNIX and Linux Forums project board.

A new project was posted on your project board. Project title: Bash Shell Tutoring Estimated Budget: $50/hr Start date: Immediately Required skills: Linux, Bash, Shell, UNIX I work as a datawarehouse designer and developer. Although I usually stick to the role of an analyst,... (0 Replies)
Discussion started by: Neo
0 Replies

3. UNIX and Linux Applications

Need ideas for graduation project based on unix or linux Need ideas for graduation project based on

Dear all, i am in last year of electronics department in engineering faculty i need suggestions for a graduation project based on unix or free bsd or linux and electronics "embedded linux " i think about embedded unix for example or device drivers please i need helps (1 Reply)
Discussion started by: MOHA-1
1 Replies

4. Solaris

what is the use of /etc/project file and project administration commands?

i have two doubts.. 1. what is the use /etc/project file. i renamed this file and when i tried to switch user or login with some user account the login was happening slowly. but when i renamed it to original name it was working fine... why so? 2. unix already has useradd and grouadd for... (4 Replies)
Discussion started by: chidori
4 Replies

5. Solaris

SSH doesn't pick up user's project from /etc/project

We have a system running ssh. When a user logs in, they do not get the project they are assigned to (they run under "system"). I verify the project using the command "ps -e -o user,pid,ppid,args,project". If you do a "su - username", the user does get the project they are assigned to (and all... (2 Replies)
Discussion started by: kurgan
2 Replies

6. What is on Your Mind?

r-project

Hi folks, Any folk has experience on r-Project; The R Project for Statistical Computing Please shed me some light on its main application with examples. The package is availabl on Ubuntu repo; $ apt-cache policy r-base-html r-base-html: Installed: (none) Candidate: 2.4.1-1 ... (0 Replies)
Discussion started by: satimis
0 Replies

7. Programming

a little project i need some help with

Hell everyone, i am trying to write a program for work, i am doing an internship there, where the program will list all the files on the Unix Server(soloaris 9) for all the engineers to look at. The code i have so far works to display all files, but the program also needs to check and see if the... (3 Replies)
Discussion started by: ShenTech
3 Replies

8. Linux

project

hi, iam doing my MCA finial year project in linux-c language.my project name 'stream control transmission protocol'.it is about message passing to server from client through packet,please help in this i want to know the coding for this or tell me the any link for this coding. ... (0 Replies)
Discussion started by: anurakrish
0 Replies

9. UNIX for Dummies Questions & Answers

project

i want to do hospital project in c++ or java in unix/linux platforms what are the required softwares i should have and how to install oracle,java in linux (1 Reply)
Discussion started by: nrusimha
1 Replies
Login or Register to Ask a Question