Ok the program is done but when it runs and u start give what it asks
Example:
How many athletes; 2 (we give 2)
***Give Athletes Data:
Lastname: Messi
First Jump: 5.6
etc....
Instead of the above it asks for:
How many athletes; 2 (we give 2)
***Give Athletes Data:
Lastname: First Jump: 5.6
etc....
IT SKIPS the first lastname but it asks u for the second properly
What the heck is that ^^
Code:
#include <cstdlib>
#include <iostream>
using namespace std;
struct athlete
{
char lastname[40];
float p1,p2,p3,p4;
};
void show_athletes(athlete A[], int MAX_ATHLETES);
int main(int argc, char *argv[]){
int MAX_ATHLETES;
cout << "How many Athletes; ";
cin >> MAX_ATHLETES;
athlete* A = new athlete[MAX_ATHLETES];
int i;
for(i=0;i<MAX_ATHLETES;i++){
printf("\n*** Give Athletes Data: \n");
printf("Lastname: ");
gets(A[i].lastname);
do{
printf("First Jump: ");
scanf("%f",&A[i].p1);getchar();
}while(A[i].p1<0);
do{
printf("Second Jump: ");
scanf("%f",&A[i].p2);getchar();
}while(A[i].p2<0);
do{
printf("Third Jump: ");
scanf("%f",&A[i].p3);getchar();
}while(A[i].p3<0);
do{
printf("Fourth Jump: ");
scanf("%f",&A[i].p4);getchar();
}while(A[i].p4<0);
}
printf("Press Enter to Show Athletes with Jumps longer than 7.50");
getchar();
show_athletes(A,MAX_ATHLETES);
system("PAUSE");
return EXIT_SUCCESS;
}
void show_athletes(athlete A[],int MAX_ATHLETES){
int i;
for(i=0;i<MAX_ATHLETES; i++){
if (A[i].p1>7.5 || A[i].p2>7.5 || A[i].p3>7.5 || A[i].p4>7.5) {
printf("The Athlete:%40s Jumped Longer than 7.50\n",A[i].lastname);
printf("Ta almata tou einai:\n%f\n%f\n%f\n%f\n",A[i].p1,A[i].p2,A[i].p3,A[i].p4); }
}
}