Can someone help me Create a program that allows the user to

Can someone help me
Create a program that allows the user to enter the gender (either F or M) and GPA (0.0 through 4.0) for any number of students. The program should calculate and display the average GPA for all students, the average GPA for male students, and the average GPA for female students. If necessary, create a new project named lntermediate23 Project, and save it in the Cpp8\\Chap07 folder. Enter the C++ instructions into a source file named Intermediate23.cpp. Also enter appropriate comments and any additional instructions required by the compiler. Save, run, and test the program.

Solution

#include <iostream>
using namespace std;
int main(void)
{
   char ch;
   float gpa,mgpa,fgpa;
   int m,f;
   m=0;f=0;mgpa=0;fgpa=0;
   cout<<\"Enter gender and gpa(q to quit):\";
   while(true)
   {
       cin>>ch;
       if(ch==\'q\')
       {
           break;
       }
       cin>>gpa;
       if(ch==\'M\')
       {
           m++;
           mgpa+=gpa;
       }
       else if(ch==\'F\')
       {
           f++;
           fgpa+=gpa;
       }
       else
       {
           cout<<\"unknown input\"<<endl;
       }
       cout<<\"Enter gender and gpa(q to quit):\";
   }
   if(m>0)
   {
       cout<<\"The average gpa for male students is \"<<mgpa/m<<endl;
   }
   else
   {
       cout<<\"There are no male students\"<<endl;
   }
   if(f>0)
   {
       cout<<\"The average gpa for female students is \"<<fgpa/f<<endl;
   }
   else
   {
       cout<<\"There are no female students\"<<endl;
   }


   return 0;
}

Can someone help me Create a program that allows the user to enter the gender (either F or M) and GPA (0.0 through 4.0) for any number of students. The program
Can someone help me Create a program that allows the user to enter the gender (either F or M) and GPA (0.0 through 4.0) for any number of students. The program

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site