Database Applications for Managers Spring 2008  BU4040

Home  |  Syllabus  |  Journal  | Project Exam Research  |  Gallery

Journal Wednesday February 27, 2008

THIS WORK BELOW IS DUE ON MONDAY FIRST 1/2 OF THE CLASS

 

- We will retake the test to the online and we will log on to:   https://oldwestbury.sln.suny.edu/frames.aspx and log in.

 

1 -On page 297 run the program as is FIRST

2 -Change this so it becomes a Membership Database such as username and password.

3 - Encrypt the password before saving it to the file.

Today we will show you a program in Dev C++ from page 297.

Each student should reproduce the program on their own workstation.   The program above does not have all of the functions declared and will not compile.

Below is version 2 of the program with all of the functions coded.

#include<iostream>
using namespace std;
char rfappend(){
cout<<"Append Under Construction "<<endl;
return 0;
}
char rfdisplay(){
cout<<"Append Under Construction "<<endl;
return 0;
}
char rfsearch(){
cout<<"Append Under Construction "<<endl;
return 0;
}
char rfmodify(){
cout<<"Append Under Construction "<<endl;
return 0;
}
char rfdelete(){
cout<<"Append Under Construction "<<endl;
return 0;
}
main(){char option;
cout<<"SELECT ONE OF THE FOLLOWING "<<endl;
cout<<"\t TYPE 1 TO INSERT "<<endl;
cout<<"\t TYPE 2 TO DISPLAY "<<endl;
cout<<"\t TYPE 3 TO SEARCH "<<endl;
cout<<"\t TYPE 4 TO MODIFY"<<endl;
cout<<"\t TYPE 5 TO DELETE "<<endl;
cout<<"\t TYPE # TO QUIT "<<endl<<endl;
cin>>option;
switch(option){
case '1': rfappend();
break;
case '2': rfdisplay();
break;
case '3': rfsearch();
break;
case '4': rfmodify();
break;
case '5': rfdelete();
break;
case '#': cout<<"BYE "<<endl;
exit(1);
break;}//SWITCH
system ("Pause");
return 0;
}
 

Testing our program...

Testing is VERY important.   Many databases and programs are not tested enough.

Make your messages friendly and clear.

#include<iostream>
using namespace std;
char rfappend(){
cout<<"Append Under Construction "<<endl;
return 0;
}
char rfdisplay(){
cout<<"Display Under Construction "<<endl;
return 0;
}
char rfsearch(){
cout<<"Search Under Construction "<<endl;
return 0;
}
char rfmodify(){
cout<<"Modify Under Construction "<<endl;
return 0;
}
char rfdelete(){
cout<<"Delete Under Construction "<<endl;
return 0;
}
main(){char option;
while(1){
cout<<"SELECT ONE OF THE FOLLOWING "<<endl;
cout<<"\t TYPE 1 TO INSERT "<<endl;
cout<<"\t TYPE 2 TO DISPLAY "<<endl;
cout<<"\t TYPE 3 TO SEARCH "<<endl;
cout<<"\t TYPE 4 TO MODIFY"<<endl;
cout<<"\t TYPE 5 TO DELETE "<<endl;
cout<<"\t TYPE # TO QUIT "<<endl<<endl;
cin>>option;
switch(option){
case '1': rfappend();
break;
case '2': rfdisplay();
break;
case '3': rfsearch();
break;
case '4': rfmodify();
break;
case '5': rfdelete();
break;
case '#': cout<<"BYE "<<endl;
exit(1);
break ;
default: cout<<"Enter 1 to 5"<<endl;
}//SWITCH
}//WHILE
system ("Pause");
return 0;
}

The code with the append function

#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
char rfappend(char personname[], char phone[]){
ofstream fout("directory.in",ios::app);
cout<<"ENTER PERSON NAME ";
cin>>personname;
cout<<"ENTER THE PHONE NUMBER ";
cin>>phone;
fout<<personname<<setw(20)<<phone<<endl;
fout.close();

return 0;
}
char rfdisplay(char personname[], char phone[]){
ifstream fin ("directory.in");
while (fin>>personname>>phone){
cout<<"PERSON NAME IS "<<personname<<endl<<endl;
cout<<"PHONE IS "<<phone<<endl<<endl; }//WHILE
fin.close();
return 0; }
char rfsearch(){
cout<<"Search Under Construction "<<endl;
return 0;
}
char rfmodify(){
cout<<"Modify Under Construction "<<endl;
return 0;
}
char rfdelete(){
cout<<"Delete Under Construction "<<endl;
return 0;
}
main()
{char personname[100], phone[10],option;
while(1){
cout<<"SELECT ONE OF THE FOLLOWING "<<endl;
cout<<"\t TYPE 1 TO INSERT "<<endl;
cout<<"\t TYPE 2 TO DISPLAY "<<endl;
cout<<"\t TYPE 3 TO SEARCH "<<endl;
cout<<"\t TYPE 4 TO MODIFY"<<endl;
cout<<"\t TYPE 5 TO DELETE "<<endl;
cout<<"\t TYPE # TO QUIT "<<endl<<endl;
cin>>option;
switch(option){
case '1': rfappend(personname,phone);
break;
case '2': rfdisplay(personname,phone);
break;
case '3': rfsearch();
break;
case '4': rfmodify();
break;
case '5': rfdelete();
break;
case '#': cout<<"BYE "<<endl;
exit(1);
break ;
default: cout<<"Enter 1 to 5"<<endl;
}//SWITCH
}//WHILE
system ("Pause");
return 0;
}
 

This program will send out the input to a file called directory.in.

Binary vs. Text files

Binary files are used to store executable code, Text Files are used to store raw text from the system.
 

For Last year notes : Class notes