/* andrew callahan
   cpsc 01 lab sept 16 2022
   lab #3 lab section #005
   Using a loop to check if the user input is a valid or ivalid chacacter unitl they quit the out of the code
*/


#include <stdio.h>

int main (void) {
	char input;
	printf ("Enter an a for apple or o for orange, or q to quit:");
	scanf (" %c" , &input );
	
while(input != 'q')

	if (input == 'a' || input == 'A')
		{
			printf("You chose apples!\n");
			printf("Enter an a for apple or o for orange, or q to quit:");
			scanf(" %c" , &input );
		}
	else if ( input == 'o' || input == 'O')
		{
			printf("You chose oranges!\n");
			printf("Enter an a for apple or o for orange, or q to quit:");
			scanf(" %c" , &input );
		}
	else
		{
			printf("You entered an invalid letter\n");
			printf("Enter an a for apple or o for orange, or q to quit:");
			scanf(" %c" , &input );
		}
		if ( input == 'q')
			{
				printf("Good bye!\n");
			}
return 0;
}
				


