Can someone help me Create a program that allows the user to
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;
}

