FINALLY i have completed both C++ classes. The intermediate C++ course i just passed this recent semester, we had to create a file on the c: and open the file, load the shit from in it, and display it on the screen. I fucking spent hours trying to load the fucker, but it wouldnt do shit. DEBUG DEBUG DEBUG!!!!
Then I let my uncle have a look at it, and somehow with his magical fingers, he was able to get it working. We also had to load arrays, sort them (bubble sort array) and bunch of other stuff.
I have potential in programming. I don't want to give up. When I was working on my other assignments and I ran them, they didnt work, so I spent time debugging and when I ran it again, it worked fine. You get that feeling of enjoyment when you spend hours on coding and it fucking runs without throwing syntax errors!
I will still continue to code on my free time to learn more. Even though I had tough times in this class, I still enjoyed it. It was a fun ride.
My brain got tired after staring at the screen for weeks. Now for the upcoming semester, I'm taking access programming.
Here is sample of some code I did.
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
char answer = 'y';
double passengers, flight_no, menu_option;
string origin, repeat_prog, destination, flight_code, c, d, o, D, C, O, cancelled, ontime, delayed;
ofstream fout;
ifstream fin;
void setup ();
void input ();
void output ();
void menu();
int main()
{
setup();
cout << "Is this correct program you want to run" << endl;
cout << "Please type Y(y) for yes and N(n) for no" << endl;
cin >> repeat_prog;
while ( repeat_prog != "y" && repeat_prog != "n" )
{
cout << "ERROR!!" << endl;
cout << "Please type Y for yes and N for no" << endl;
cin >> repeat_prog;
}
if ( repeat_prog == "n" || repeat_prog == "N")
{
return 0;
}
menu();
system("pause");
return 0;
}
void setup()
{
delayed = "d";
cancelled = "c";
ontime = "o";
}
void menu()
{
menu_option = 1;
while (menu_option != 3)
{
cout << endl;
cout << "1. Create a new file"
<< endl;
cout << "2. Open created file"
<< endl;
cout << "3. End the program" << endl;
cout << endl;
cout << "Choose a menu option: ";
cin >> menu_option;
cout << endl;
if (menu_option == 3) break;
if ( menu_option == 1 )
input();
if ( menu_option == 2 )
output();
}
cout << "Program Ended..." << endl;
}
void input()
{
//File init
fout.open ("c:\\study\\airline_data.txt",ifstream::app);
fout.seekp(0,ios::end);
//Data input
cout << "Flight No: ";
cin >> flight_no;
cout << "Origin: ";
cin >> origin;
cout << "Destination: ";
cin >> destination;
cout << "Passengers: ";
cin >> passengers;
cout << "Flight Code:";
cin >> flight_code;
//Data validation
while ( flight_code != "d" && flight_code != "c" && flight_code != "o" && flight_code != "D" && flight_code != "C" && flight_code != "O" )
{
cout << "ERROR!!" << endl;
cout << "Please type d for delayed, c for cancelled, o for ontime!" << endl;
cin >> flight_code;
}
//save data
fout << flight_no << origin << destination << passengers << flight_code;
//close file
fout.close();
}
void output()
{
fin.open("C:\\study\\airline_data.txt");
fin.seekg(0,ios::beg);
while ( !fin.eof() )
{
fin >> flight_no >> origin >> destination >> passengers >> flight_code;
cout << flight_no << "\t";
cout << origin << "\t";
cout << destination << "\t";
cout << passengers << "\t";
cout << flight_code << "\t";
}
fin.close ();
}