All pastes #638779 Raw Edit

Stuff

public text v1 · immutable
#638779 ·published 2007-07-30 02:38 UTC
rendered paste body
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>

#define SIZE 3

void checkAge(int);
void checkGPA(float);
void DisplayOutput();

float userGPA;

struct userType
{
	char szState[15];
	char szfName[15];
	char szlName[20];
	char szSpouse[15];
	char cMarried;
	int iAge, iCount;
}SInterview[SIZE];

int main() {
	int iCount = 0;
	int iCount2 = 0;
	for( ; iCount2 < SIZE; iCount2++)
	{

	printf("Hello, my name is Lerie. What is your name? ");
	gets(SInterview[iCount2].szfName);

	SInterview[iCount2].szfName[0] = toupper(SInterview[iCount2].szfName[0]);

	if(strlen(SInterview[iCount2].szfName) > 8)
	{
		printf("wow, thats a long name!");
	}
	else
	{
		printf("at least your name isnt real long\n\n");
	}

	printf("OK %s what is your last name? ", SInterview[iCount2].szfName);
	gets(SInterview[iCount2].szlName);

	SInterview[iCount2].szfName[0] = toupper(SInterview[iCount2].szfName[0]);

	if(strlen(SInterview[iCount2].szlName) > 7)
	{
		printf("Last name is longer than mine!\n\n");
	}
	else
	{
		printf("not much to type for that name.\n\n");
	}

	SInterview[iCount2].szlName[0] = toupper(SInterview[iCount2].szlName[0]);

	printf("How old are you %s? ", SInterview[iCount2].szfName);
	scanf("%d", &SInterview[iCount2].iAge);
	fflush(stdin);

	checkAge(SInterview[iCount2].iAge);

	printf("What state do you reside in, %s? ", SInterview[iCount2].szfName);
	gets(SInterview[iCount2].szState);

	SInterview[iCount2].szState[0] = toupper(SInterview[iCount2].szState[0]);
	for(iCount = 1; iCount < (int) strlen(SInterview[iCount2].szState); iCount++)
	{
		if(SInterview[iCount2].szState[iCount -1] == ' ')
			SInterview[iCount2].szState[iCount] = toupper(SInterview[iCount2].szState[iCount]);
		else 
			SInterview[iCount2].szState[iCount] = tolower(SInterview[iCount2].szState[iCount]);
	}

	printf("%s is a nice place, I think i've been there before\n\n", SInterview[iCount2].szState);

	printf("What is your GPA %s? ", SInterview[iCount2].szfName);
	scanf("%f", &userGPA);
	fflush(stdin);
	checkGPA(userGPA);

	printf("Are you married? ");
	scanf("%c", &SInterview[iCount2].cMarried);
	fflush(stdin);

	if(SInterview[iCount2].cMarried == 'y')
	{
		printf("What is your spouse's name? kw3rln ");
		gets(SInterview[iCount2].szSpouse);
		SInterview[iCount2].szSpouse[0] = toupper(SInterview[iCount2].szSpouse[0]);

		printf("%s is a nice name.\n\n", SInterview[iCount2].szSpouse);
	}
	else
	{
		printf("It's never to late!\n\n");
	}
	system("cls");
	}//end for loop
	printf("Press any key to continue....\n");
	getch();
	DisplayOutput();

	return 0;
}

void checkGPA(float userGPA)
{
	if(userGPA > 4.0f)
	{
		printf("Wow, you're mom must be proud\n\n");
	}
	else
	{//end if
		if(userGPA == 4.0f)
		{
			printf("Excellent, a straight A student!\n\n");
		}
		else
		{//end if
			if(userGPA >= 3.0f)
			{
				printf("Almost a straight A student\n\n");
			}
			else
			{//end if
				if(userGPA >= 2.0f)
				{
					printf("Well that doesn't look very good...\n\n");
				}
				else
				{//end if
					if(userGPA >= 1.0f)
					{
						printf("That is a very very poor grade point average!\n\n");
					}
					else
					{//end if
						if(userGPA >= 0.0f)
						{
							printf("Did you even attend a school?\n\n");
						}//end if
					}//end else
				}//end else
			}//end else
		}//end else
	}//end else
}

void checkAge(int iAge)
{
	if(iAge < 18)
	{
		printf("Your still a minor.\n\n");
	}//end if
	else
	{
		if(iAge >= 21)
		{
			printf("At least you can buy beer.\n\n");
		}//end if
		else
		{
			if(iAge >= 30)
			{
				printf("Your thirties should be a good time.\n\n");
			}//end if
			else
			{
				if(iAge >= 50)
				{
					printf("About over the hill, yea?\n\n");
				}//end if
			}//end else
		}//end else
	}//end else
}//end checkage

void DisplayOutput() {
	int iCount3 = 0;
		for( ; iCount3 < SIZE; iCount3++)
		{
		printf("------------------------------------------\n");
		printf("Your name is %s %s.\n", SInterview[iCount3].szfName, SInterview[iCount3].szlName);
	
			if(SInterview[iCount3].cMarried == 'y')
			{
				printf("You are married, your spouses name is %s.\n", SInterview[iCount3].szSpouse);
			}
			else
			{
				printf("You are not married.\n");
			}

			printf("You are %d years old.\n", SInterview[iCount3].iAge);
			printf("You live in %s\n\n",SInterview[iCount3].szState);

		}
}