Ok so this is what i have so far... Its about done for what i can see but im having problems when it gets to the reading in gender. Im assuming that i have syntax problems with readin in the name and or age. Please help anything would be nice.
Sorry about the spacing im sure there was a BB code to fix it... If an Admin or Mod can edit it that would be fine.
Code:
#include
<stdlib.h>
#include
<stdio.h>
#include
<string.h>
#define
pause system("pause")
typedef
struct {
char yourName[25];
int age;
char gender;
} RECORD1;
typedef
struct {
char yourName[25];
int age;
char gender;
} RECORD2;
typedef
struct {
char yourName[25];
int age;
char gender;
} RECORD3;
typedef
struct {
char yourName[25];
int age;
char gender;
} RECORD4;
typedef
struct {
char yourName[25];
int age;
char gender;
} RECORD5;
//void displaySquare(RECORDS *birthday)
//{
// printf("%02i / %02i / %04i \n" , birthday->month , birthday->day , birthday->year);
//
//}
//DISPLAY 3th record
void
printEmployee(RECORD3 *emp) {
printf(
"Bankers name : %s.\n", emp->yourName);
printf(
"Bankers age : %i.\n", emp->age);
printf(
"Bakers gender : %c\n", emp->gender);
}
int
main()
{
RECORD1 teacher;
RECORD2 student;
RECORD3 banker;
RECORD4 tester;
RECORD5 gamer;
int choice = 0;
int number = 0;
int numberSquared = 0;
/*strcpy(student.yourName, "Justin");
student.age = 19;
student.gender = 'M';*/
do{
printf(
"What would you like to do?\n");
printf(
"1)Diplay the square of a number\n");
printf(
"2)Enter 5 records\n");
printf(
" A.Name\n");
printf(
" B.Age\n");
printf(
" C.Gender\n");
printf(
"3)Diplay the 3th record\n");
printf(
"4)quit the program\n");
scanf(
"%i" , &choice);
//error checking
while(choice < 1 || choice > 4)
{
printf(
"Sorry that is not a choice please enter a valid choice: ");
scanf(
"%i" , &choice);
}
if(choice == 1)
{
printf(
"Enter a number to square: ");
scanf(
"%i" , &number);
numberSquared = number * number;
printf(
"The number %i squared is %i " , number , numberSquared);
}
if(choice == 2)
{
printf(
"Enter in the name of the teacher: ");
scanf(
"%s" , &teacher.yourName);
printf(
"Enter in the age of the teacher: ");
scanf(
"%i" , &teacher.age);
printf(
"Enter in the gender of the teacher: ");
scanf(
"%c" , &teacher.gender);
system(
"cls");
printf(
"Enter in the name of the student: ");
scanf(
"%s" , &student.yourName);
printf(
"Enter in the age of the student: ");
scanf(
"%i" , &student.age);
printf(
"Enter in the gender of the student: ");
scanf(
"%c" , &student.gender);
system(
"cls");
printf(
"Enter in the name of the banker: ");
scanf(
"%s" , &banker.yourName);
printf(
"Enter in the age of the banker: ");
scanf(
"%s" , &banker.age);
printf(
"Enter in the gender of the banker: ");
scanf(
"%c" , &banker.gender);
system(
"cls");
printf(
"Enter in the name of the tester: ");
scanf(
"%s" , &tester.yourName);
printf(
"Enter in the age of the tester: ");
scanf(
"%i" , &tester.age);
printf(
"Enter in the gender of the tester: ");
scanf(
"%c" , &tester.gender);
system(
"cls");
printf(
"Enter in the name of the gamer: ");
scanf(
"%s" , &gamer.yourName);
printf(
"Enter in the age of the student: ");
scanf(
"%i" , &gamer.age);
printf(
"Enter in the gender of the student: ");
scanf(
"%c" , &gamer.gender);
system(
"cls");
}
if(choice == 3)
{
//Show 3th record
printEmployee(&banker);
}
pause;
system(
"cls");
return 0;
}
while(choice !=4);
pause;
system(
"cls");
return 0;
}
//END MAIN