Snail
03-20-2009, 07:34 PM
So...I was rather unmotivated to learn how to use functions and prototypes. I thought the forum would like to see what I wrote up for my test today. <3 This is post test or any assignment I would have for this. Anybody who minds showing how I could possibly use prototypes and functions in this, it would be greatly appreciated so I could maybe learn something.
//1337 Programming Fundamentals II
//Test 1
//03/20/09
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
string lastName, letterGrade;
float numericGrade, aCount=0, bCount=0, cCount=0, dCount=0, fCount=0;
ifstream info;
info.open ("grades.txt");
cout << "Umbrella Corporation" << endl;
cout << "Zombie infection severity. 'A' being highest" << endl;
cout << "Effect of PROTOTYPE VIRUS AND FUNCTIONS\n" << endl;
info >> lastName
>> numericGrade;
cout << setw(20) << "Victim Name"
<< setw(20) << "Numeric Infection"
<< setw(20) << "Letter Grade"
<< "\n\n";
while(info)
{
if(numericGrade >= 90)
{
letterGrade="A";
aCount++;
}
else
if(numericGrade >= 80 && numericGrade < 90)
{
letterGrade="B";
bCount++;
}
else
if(numericGrade >= 70 && numericGrade < 80)
{
letterGrade="C";
cCount++;
}
else
if(numericGrade >=60 && numericGrade <70)
{
letterGrade="D";
dCount++;
}
else
if(numericGrade < 60)
{
letterGrade="F";
fCount++;
}
cout << setw(20) << lastName
<< setw(20) << numericGrade
<< setw(20) << letterGrade
<< endl;
info >> lastName
>> numericGrade;
}
cout << setw(10) << "Number of As = " << setw(10) << aCount << "\n"
<< setw(10) << "Number of Bs = " << setw(10) << bCount << "\n"
<< setw(10) << "Number of Cs = " << setw(10) << cCount << "\n"
<< setw(10) << "Number of Ds = " << setw(10) << dCount << "\n"
<< setw(10) << "Number of Fs = " << setw(10) << fCount << "\n\n\n\n";
cout << "CONCLUSION: The Prototype Virus and Functions are very dangerous. \n"
<< "There is no escape. \n"
<< "NO SURVIVAL KIT IS GOOD ENOUGH TO SAVE YOU!" << endl;
info.close();
return 0;
}
//1337 Programming Fundamentals II
//Test 1
//03/20/09
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
string lastName, letterGrade;
float numericGrade, aCount=0, bCount=0, cCount=0, dCount=0, fCount=0;
ifstream info;
info.open ("grades.txt");
cout << "Umbrella Corporation" << endl;
cout << "Zombie infection severity. 'A' being highest" << endl;
cout << "Effect of PROTOTYPE VIRUS AND FUNCTIONS\n" << endl;
info >> lastName
>> numericGrade;
cout << setw(20) << "Victim Name"
<< setw(20) << "Numeric Infection"
<< setw(20) << "Letter Grade"
<< "\n\n";
while(info)
{
if(numericGrade >= 90)
{
letterGrade="A";
aCount++;
}
else
if(numericGrade >= 80 && numericGrade < 90)
{
letterGrade="B";
bCount++;
}
else
if(numericGrade >= 70 && numericGrade < 80)
{
letterGrade="C";
cCount++;
}
else
if(numericGrade >=60 && numericGrade <70)
{
letterGrade="D";
dCount++;
}
else
if(numericGrade < 60)
{
letterGrade="F";
fCount++;
}
cout << setw(20) << lastName
<< setw(20) << numericGrade
<< setw(20) << letterGrade
<< endl;
info >> lastName
>> numericGrade;
}
cout << setw(10) << "Number of As = " << setw(10) << aCount << "\n"
<< setw(10) << "Number of Bs = " << setw(10) << bCount << "\n"
<< setw(10) << "Number of Cs = " << setw(10) << cCount << "\n"
<< setw(10) << "Number of Ds = " << setw(10) << dCount << "\n"
<< setw(10) << "Number of Fs = " << setw(10) << fCount << "\n\n\n\n";
cout << "CONCLUSION: The Prototype Virus and Functions are very dangerous. \n"
<< "There is no escape. \n"
<< "NO SURVIVAL KIT IS GOOD ENOUGH TO SAVE YOU!" << endl;
info.close();
return 0;
}