Professional Documents
Culture Documents
Carrol Let 2100 Lab 09
Carrol Let 2100 Lab 09
* PROGRAM:ET2100Lab09
* AUTHOR:Alexander T. Carroll
* DATE:03/25/2014
*
* DESCRIPTION
**************************************/
/* PREPROCESSOR COMMANDS */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
/* MAIN PROCESSING CONTROL */
int main()
{
char MoreYN;
char Color[7];
char Content[20];
/* VARIABLE DECLARATIONS */
printf("\nColored Canister Identifier - CCI");
printf("\n---------------------------------");
printf("\nWould you like to check a canister? (y/n): ");
fflush(stdin);
scanf("\n %c", &MoreYN);
while (toupper(MoreYN) == 'Y'){
printf("\nPlease enter the color of you canister: ");
fflush(stdin);
scanf("\n %s", &Color);
Color[0] = toupper(Color[0]);
if (strcmp(Color, "Brown") == 0){
strcpy(Content, "Carbon Dioxide");
}
else if (strcmp(Color, "Green") == 0){
strcpy(Content, "Oxygen");
}
else if (strcmp(Color, "Orange") == 0){
strcpy(Content, "Ammonia");
}
else if (strcmp(Color, "Yellow") == 0){
strcpy(Content, "Hydrogen");
}
else {
strcpy(Content, "Contents Unknown");
}
printf("\nThe %s canister contains %s.", Color, Content);
printf("\nWould you like to check another canister? (y/n): ");
fflush(stdin);
scanf("\n %c", &MoreYN);
}
/* PAUSE */
fflush(stdin);
getchar();
return 0;
}
/* END OF FILE */