Right this is what i have done so far any suggestions i am at a kinda standstill now where to go. any help would be very grateful
Code:
// Program to show use of arrays
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
#include<ctype.h>
#include<string>
void input (void);
void calc (void);
void display (void);
void percent (void);
void vvv (void);
int checknumb(char[7]);
string fname ;
string lname;
const int z = 1;
string wholename[z];
int results[z], variance[z] ;
int tot,total;
char * examn[z];
int arch[1];
float ave,ave1;
float perc[10] ;
int main(void)
{
input();
percent();
calc();
display() ;
cout<<" Please type in any key to finish"<< endl;
getch();
return 0;
}
void input (void)
{
for (int i = 0; i<z; i++)
{
char studnumber[7];
bool OK = false;
while (!OK)
{
cout<<" Enter a student number"<<endl;
cin>>studnumber;
if (checknumb(studnumber))
{
cout<<"This number is valid" <<endl;
examn[i]=studnumber;
OK = true;
}
else
cout<<" Unfortunately this number is invalid"<<endl;
}
cout<<"Type in your first name "<<endl;
cin>>fname;
cout<<"Type in your last name "<<endl;
cin>>lname;
wholename[i]= fname+" "+lname;
cout<<" Please type in result for programming "
<<(i+1)<<endl;
cin>>results[i];
cout<<" Please type in result for architecture "<<(i+1)<<endl;
cin>>arch[i];
tot+= results[i];
total+=arch[i];
}// close for loop
} // close function
int checknumb(char code[])
{
// confirm string is right length
if(strlen(code)!= 7)
return 0;
//confirm string is all digits
for (int i = 0; i<7;i++)
{
if (!isdigit(code[i]))
return 0;
}
//return -1 if all is Ok
return -1 ;
} // end checknumb
void percent(void)
{
for (int i=0;i<6;i++)
{
perc[i]=results[i]/total*100;
cout<<setiosflags(ios::showpoint|ios::fixed)
<<setprecision(2)<<perc[i]<<endl<<endl;
}
}
void calc (void)
{
ave = tot/z;
ave1 =total/z;
for (int i = 0; i <z;i++)
{
variance[i] = results[i] - ave ;
}
}
void display (void)
{
// cout<<"First Name + Last Name "<<wholename[z]<<endl; */
cout<<"\n\nTotal of Programming "<<tot<<endl;
cout<<"\n\nTotal of Arch "<<total<<endl;
cout<<"\nAverage of results of Programming "<<setiosflags(ios::showpoint|ios::fixed)<<setprecision(2)<<ave<<endl;
cout<<"\nAverage of results Of Arch "<<setiosflags(ios::showpoint|ios::fixed)<<setprecision(2)<<ave1<<endl;
cout<< "\n\n Results " << setw(20)<<"Variance"<<endl;
for (int h = 0; h<z;h++)
{
cout<<results[h]<<setw(20)<<variance[h]<<endl;
}
}
//
Code:
// Program to show use of arrays