/* Mia Kramer
 * 3/10/2023
 * CPSC 1011 Section 001
 * Lab 7
 * This lab will output the text read into the array and the total number of lines in the text.It will provide a menu to the user with choices to make.
 */

#include <stdio.h>
#include <string.h>

int main()
{

const int MAX_LINE=200;
const int MAX_LINE_LEN=100;
char max_array[MAX_LINE][MAX_LINE_LEN];
int i=0, lines = 0;
FILE *inFile=fopen("input.txt","r");
char oppositeCase[MAX_LINE][MAX_LINE_LEN];
int menuChoice;

 

while((fgets (max_array[lines], MAX_LINE_LEN, inFile)!=NULL))
{
	lines++;
	while(i<lines){
		strcpy(oppositeCase[i],max_array[i]);
		i++;
	}

	
}




for(i=0; i<lines; i++)
{
	for(int j=0; j<strlen(oppositeCase[i]); j++){
		if (max_array[i][j] >= 65 && max_array[i][j] <= 90){
			oppositeCase[i][j] = max_array[i][j] + 32;
		}
			else if (max_array[i][j] >= 97 && max_array[i][j] >= 122){
				oppositeCase[i][j] = max_array[i][j] - 32;
			}
				
	
	}	
}



while(menuChoice!=4) 
{
printf("\nChoose from the menu:\n");
printf("\t1. print the poem\n");
printf("\t2. show the number of lines in the poem\n");
printf("\t3. convert the case\n");
printf("\t4. quit\n\n");
printf("\t - - > ");
scanf("%d", &menuChoice);
printf("\n");
if (menuChoice==1){
	for(i =0; i<lines; i++)
{

        printf("%s", max_array[i]);

}
}
else if (menuChoice==2){
	

	printf(" The poem has %d lines.\n", lines);

}
else if (menuChoice==3){
	for(i=0; i<lines; i++)
{
        printf("%s", oppositeCase[i]);
}
}







}

return 0;

}


