Hello guys, I'm currently having a problem with converting uppercase to lowercase. For example in my code below when a user enters in the class number I'm trying to let them be able to type it in both uppercase and lowercase. Like instead of only being able to type ABC101, they should be able to type aBc101 or abc101 and so forth. And my last problem that I'm having is with letting the user type in their full name while using only one variable instead of three like I have it.
#include <stdio.h>
#include <string.h>
#include <iostream>
/*+*+*+*+*+*+*+* Function Prototypes *+*+*+*+*+*+*+*/
void WelcomeInfo (void); /* Welcomes the user */
void AskQuestion(void); /* Asks the user a question */
void GetInfo(void); /* Gets the input */
void GetStudentGrade(void);
void NameofStudent(void);
void PerformCalc(void); /* Performs the calculation */
void GradeDisplay(void);
void Totals(void);
void WeightedGrade(void);
void AskQuestion2(void); /* Asks the user a question */
void PrintAStarLine(void);
void TotalPageDisplay(void);
/*+*+*+*+*+*+*+* Variables *+*+*+*+*+*+*+*/
float test1;
float test2;
float project1;
float project2;
float midterm;
float final;
float tests;
float projects;
float midtermexam;
float finalexam;
float studentgrade;
int bonus = 0;
float totalaverage;
int totalstudents;
int studentA = 0;
int studentB = 0;
int studentC = 0;
int studentD = 0;
int studentF = 0;
char courseNumber[10];
char cName;
char cMore;
char firstName[25];
char middleName[25];
char lastName[25];
char StudentfirstName[25];
char StudentmiddleName[25];
char StudentlastName[25];
char studentandgrade;
/*+*+*+*+*+*+*+*^ The Main Module ^*+*+*+*+*+*+*+*/
main()
{
cName = 'N';
do
{
WelcomeInfo();
AskQuestion();
} while ((cName != 'Y') && (cName != 'y'));
cMore = 'Y';
do
{
GetInfo();
system("cls");
NameofStudent();
system("cls");
GetStudentGrade();
system("cls");
PerformCalc();
WeightedGrade();
system("cls");
GradeDisplay();
AskQuestion2();
}while ((cMore != 'N') && (cMore != 'n')); /* It will loop until user enter N */
Totals();
TotalPageDisplay();
return 0;
}
/*+*+*+*+*+*+*+* Welcomes The User *+*+*+*+*+*+*+*/
void WelcomeInfo (void)
{
printf("Enter your name please. ");
scanf(" %s %s %s", &firstName, &middleName, &lastName);
printf("\n\n\n");
printf("\t\t\t\tWelcome %s %s %s \n", firstName, middleName, lastName);
printf("\n\n\n");
return;
}
/*+*+*+*+*+*+*+* Asks The User A Question *+*+*+*+*+*+*+*/
void AskQuestion(void)
{
printf("\n\nIs this your name? (Y/N)"); /* prints the description */
scanf(" %c", &cName); /* get the input */
fflush(stdin); /* flush the CRLF */
return;
}
/*+*+*+*+*+*+*+* Retrieves The Input *+*+*+*+*+*+*+*/
void GetInfo(void)
{
/***** Course Number *****/
printf("\n\nEnter one of the following course numbers. ");
printf("\n");
printf("(ABC101, HIS220, HOT707, ECO122, PLE888)\n ");
scanf(" %s", &courseNumber);
if(strcmp(courseNumber,"ABC101")==0)
{
printf("\n Welcome to class ABC101 \n");
printf("\n\n\n");
}
else if(strcmp(courseNumber,"HIS220")==0)
{
printf("\n Welcome to class HIS220 \n");
printf("\n\n\n");
}
else if(strcmp(courseNumber,"HOT707")==0)
{
printf("\n Welcome to class HOT707 \n");
printf("\n\n\n");
}
else if(strcmp(courseNumber,"EC0122")==0)
{
printf("\n Welcome to class ECO122 \n");
printf("\n\n\n");
}
else if(strcmp(courseNumber,"PLE888")==0)
{
printf("\n Welcome to class PLE888 \n");
printf("\n\n\n");
}
else
{
printf("\n That course number does not exist, please try again. \n");
printf("\n\n\n");
}
return;
}
void WeightedGrade(void)
{
if(strcmp(courseNumber,"ABC101")==0)
{
studentgrade = studentgrade + ((tests * .23) + (projects * .27) + (midtermexam * .20) + (finalexam * .30) + (bonus));
}
else if(strcmp(courseNumber,"HIS220")==0)
{
studentgrade = studentgrade + ((tests * .20) + (projects * .30) + (midtermexam * .25) + (finalexam * .25) + (bonus));
}
else if(strcmp(courseNumber,"HOT707")==0)
{
studentgrade = studentgrade + ((tests * .25) + (projects * .50) + (midtermexam * .15) + (finalexam * .10) + (bonus));
}
else if(strcmp(courseNumber,"EC0122")==0)
{
studentgrade = studentgrade = ((tests * .25) + (projects * .25) + (midtermexam * .20) + (finalexam * .30) + (bonus));
}
else if(strcmp(courseNumber,"PLE888")==0)
{
studentgrade = studentgrade + ((tests * .30) + (projects * .20) + (midtermexam * .25) + (finalexam * .25) + (bonus));
}
return;
}
void NameofStudent(void)
{
printf("Enter the student's Full Name(First Middle Last) . ");
scanf( "%s %s %s", &StudentfirstName, &StudentmiddleName, &StudentlastName);
printf("\n\n\n");
return;
}
void GetStudentGrade(void)
{
printf(" Enter the grades of %s %s %s \n", StudentfirstName, StudentmiddleName, StudentlastName);
printf("\n\n\n");
printf("Enter grade for Test1: ");
scanf(" %f", &test1);
printf("Enter grade for Test2: ");
scanf(" %f", &test2);
printf("Enter grade for Project1: ");
scanf(" %f", &project1);
printf("Enter grade for Project2: ");
scanf(" %f", &project2);
printf("Enter grade for Midterm: ");
scanf(" %f", &midterm);
printf("Enter grade for Final: ");
scanf(" %f", &final);
printf("Number of Bonus Projects: ");
scanf(" %d", &bonus);
fflush(stdin);
return;
}
/*+*+*+*+*+*+*+* Performs All The Calculations *+*+*+*+*+*+*+*/
void PerformCalc(void)
{
tests = tests + (test1 + test2) / 2;
projects = projects + (project1 + project2) / 2;
midtermexam = midtermexam + (midterm);
finalexam = finalexam + (final);
if (bonus >= 1 && bonus <= 5)
{
bonus = 1;
}
else if (bonus >= 6 && bonus <= 9)
{
bonus = 3;
}
else if (bonus >= 10 && bonus <= 12)
{
bonus = 4;
}
else if(bonus >= 13)
{
bonus = 6;
}
else
{
bonus = 0;
}
return;
}
void Totals(void)
{
if (studentgrade > 90)
studentA = studentA + 1;
else if (studentgrade >= 80 && studentgrade <= 89)
studentB = studentB + 1;
else if (studentgrade >= 72 && studentgrade <=79)
studentC = studentC + 1;
else if (studentgrade >= 70 && studentgrade <= 71)
studentD = studentD + 1;
else if (studentgrade <= 69)
studentF = studentF + 1;
totalstudents = totalstudents + (studentA + studentB + studentC + studentD + studentF);
totalaverage = totalaverage + (studentgrade);
return;
}
void GradeDisplay(void)
{
printf("Test Scores: %10.3f\n", tests);
printf("Project Scores: %10.3f\n", projects);
printf("Midterm Score: %10.3f\n", midtermexam);
printf("Final Score: %10.3f\n", finalexam);
printf("Bonus Points: %d\n", bonus);
printf("Student Grade: %10.3f\n", studentgrade);
fflush(stdin);
return;
}
/*+*+*+*+*+*+*+* Asks The User A Question *+*+*+*+*+*+*+*/
void AskQuestion2(void)
{
printf("\n\nWould you like to enter in grades again? (Y/N)"); /* print description */
scanf(" %c", &cMore); /* get the input */
fflush(stdin); /* flush the CRLF */
return ;
}
void PrintAStarLine(void)
{
printf("******************************************************************************** \n");
printf("\n\n");
return;
}
void TotalPageDisplay(void)
{
system("cls");
PrintAStarLine();
printf("\t\t\t\tSchool Grade Totals \n");
printf("\n\n");
PrintAStarLine();
printf("Grade\t\t\t Total Students \n", studentandgrade);
printf("A\t\t\t %d\n", studentA);
printf("B\t\t\t %d\n", studentB);
printf("C\t\t\t %d\n", studentC);
printf("D\t\t\t %d\n", studentD);
printf("F\t\t\t %d\n", studentF);
printf("\n\n");
printf("__________________________________________________________________________ \n");
printf("GrandTotal number of Students: %d\n", totalstudents);
printf("\n");
printf("Overall average of all students: %6.2f\n", totalaverage);
printf("\n");
return;
}