C
chaching
Please help. The code below will compile and run using the Dev C
compiler, but not the Visual C++ 2005 express edition. I need it to
run in the express editions. any suggestions?
#include "stdafx.h"
#include <iostream>
#include <string>
#include <stdlib.h>
#include <algorithm>
using namespace std;
using std::cout;
using std::cin;
class student
{
public:
student();
void student1Input(string fName, string lName, int id);
void student2Input(string fName, string lName, int id);
int student1maxMin();
int student2maxMin();
private:
int id, max, min;
double sum, avg;
char fName, lName;
};
student::student()
{
}
void student::student1Input(string fName, string lName, int id)
{
cout<<"\n..........Enter first student's information........\n";
cout<<"Student's ID: ";
cin>>id;
cout<<"First Name: ";
cin>>fName;
cout<<"Last Name: ";
cin>>lName;
cout<<"Grades: 95 78 26 92 27 46 89 83 78 90";
cout<<endl;
sum = 95+78+26+92+27+46+89+83+78+90;
avg = sum/10;
cout<<"Average: "<<avg;
cout<<"\nStudent 1: ";
int array[] = {95,78,26,92,27,46,89,83,78,90 };
int elements = sizeof(array) / sizeof(int);
std::sort(array, array + elements);
for (int i = 0; i < elements; ++i) std::cout<< array << ' ';
cout<<endl;
cout<<endl;
}
void student::student2Input(string fName, string lName, int id)
{
cout<<"\n..........Enter second student's information........\n";
cout<<"Student's ID: ";
cin>>id;
cout<<"First Name: ";
cin>>fName;
cout<<"Last Name: ";
cin>>lName;
cout<<"Grades: 100 98 97 67 59 100 98 76 83 85";
cout<<endl;
sum = 100+98+97+67+59+100+98+76+83+85;
avg = sum/10;
cout<<"Average: "<<avg;
cout<<"\nStudent 2:";
int array[] = {100,98,97,67,59,100,98,76,83,85 };
int elements = sizeof(array) / sizeof(int);
std::sort(array, array + elements);
for (int i = 0; i < elements; ++i) std::cout<<array << ' ';
cout<<endl;
cout<<endl;
}
int student::student1maxMin()
{
int array[] = {95,78,26,92,27,46,89,83,78,90 };
max = array[0];
for(int i = 0; i < 10; i++)
if( max < array )
max = array;
min = array[0];
for(int i = 0; i < 10; i++)
if( min > array )
min = array;
cout<<"1\t \t \t "<<min<<"\t \t \t "<<max<<endl;
}
int student::student2maxMin()
{
int array[] = {100,98,97,67,59,100,98,76,83,85 };
max = array[0];
for(int i = 0; i < 10; i++)
if( max < array )
max = array;
min = array[0];
for(int i = 0; i < 10; i++)
if( min > array )
min = array;
cout<<"2\t \t \t "<<min<<"\t \t \t "<<max<<endl;
}
int main()
{
string fName, lName; int id;
student averages;
averages.student1Input(fName, lName, id);
averages.student2Input(fName, lName, id);
cout<<"Student\t \t \t Lowest\t \t \tHigest\n";
cout<<"------------------------------------------------------\n";
averages.student1maxMin();
averages.student2maxMin();
return 0;
}
compiler, but not the Visual C++ 2005 express edition. I need it to
run in the express editions. any suggestions?
#include "stdafx.h"
#include <iostream>
#include <string>
#include <stdlib.h>
#include <algorithm>
using namespace std;
using std::cout;
using std::cin;
class student
{
public:
student();
void student1Input(string fName, string lName, int id);
void student2Input(string fName, string lName, int id);
int student1maxMin();
int student2maxMin();
private:
int id, max, min;
double sum, avg;
char fName, lName;
};
student::student()
{
}
void student::student1Input(string fName, string lName, int id)
{
cout<<"\n..........Enter first student's information........\n";
cout<<"Student's ID: ";
cin>>id;
cout<<"First Name: ";
cin>>fName;
cout<<"Last Name: ";
cin>>lName;
cout<<"Grades: 95 78 26 92 27 46 89 83 78 90";
cout<<endl;
sum = 95+78+26+92+27+46+89+83+78+90;
avg = sum/10;
cout<<"Average: "<<avg;
cout<<"\nStudent 1: ";
int array[] = {95,78,26,92,27,46,89,83,78,90 };
int elements = sizeof(array) / sizeof(int);
std::sort(array, array + elements);
for (int i = 0; i < elements; ++i) std::cout<< array << ' ';
cout<<endl;
cout<<endl;
}
void student::student2Input(string fName, string lName, int id)
{
cout<<"\n..........Enter second student's information........\n";
cout<<"Student's ID: ";
cin>>id;
cout<<"First Name: ";
cin>>fName;
cout<<"Last Name: ";
cin>>lName;
cout<<"Grades: 100 98 97 67 59 100 98 76 83 85";
cout<<endl;
sum = 100+98+97+67+59+100+98+76+83+85;
avg = sum/10;
cout<<"Average: "<<avg;
cout<<"\nStudent 2:";
int array[] = {100,98,97,67,59,100,98,76,83,85 };
int elements = sizeof(array) / sizeof(int);
std::sort(array, array + elements);
for (int i = 0; i < elements; ++i) std::cout<<array << ' ';
cout<<endl;
cout<<endl;
}
int student::student1maxMin()
{
int array[] = {95,78,26,92,27,46,89,83,78,90 };
max = array[0];
for(int i = 0; i < 10; i++)
if( max < array )
max = array;
min = array[0];
for(int i = 0; i < 10; i++)
if( min > array )
min = array;
cout<<"1\t \t \t "<<min<<"\t \t \t "<<max<<endl;
}
int student::student2maxMin()
{
int array[] = {100,98,97,67,59,100,98,76,83,85 };
max = array[0];
for(int i = 0; i < 10; i++)
if( max < array )
max = array;
min = array[0];
for(int i = 0; i < 10; i++)
if( min > array )
min = array;
cout<<"2\t \t \t "<<min<<"\t \t \t "<<max<<endl;
}
int main()
{
string fName, lName; int id;
student averages;
averages.student1Input(fName, lName, id);
averages.student2Input(fName, lName, id);
cout<<"Student\t \t \t Lowest\t \t \tHigest\n";
cout<<"------------------------------------------------------\n";
averages.student1maxMin();
averages.student2maxMin();
return 0;
}