Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Read in the a students last name , gpa and the number of hours a college student has earned. If they have earned 0 hours, then print new student, if they have eared at least 1 hour but less than 32, print freshman, 32 to 60, sophomore 61 to 90, junior and over 90 a senior. If they have over a 3.2 gpa and are within 5 hours of the next then move them up. ( Do not move up new students) Your program should work for any number of lines of data.

What I have tried:

C++
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{

   char  name;
   double gpa;
   int hours;

   while(cin>>name>>gpa>>hours)
   {
   if( hours ==0)
   {
    cout<<" New Student "<<name<<" "<<hours<<" "<<gpa<<endl;
   }else
   if(( hours ==1) &&(hours <32))
   { if((gpa >3.2)&&(hours + 5))
     cout<<" Freshman "<<name<<" "<<hours<<endl;
     cout<<" Sophomore "<<gpa<<endl;
   }else 
   if(( hours ==32) &&(hours <=60))
   { if((gpa >3.2) && (hours + 5))
     cout<<" Sophomore "<<name<<" "<<hours<<endl;
     cout<<" Junior "<<gpa<<endl;
   }else
   if(( hours ==61)&& (hours <=90))
   { if((gpa >3.2) &&(hours + 5))
     cout<<" Junior "<<name<<" "<<hours<<endl;
     cout<<" Senior "<<gpa<<endl;
   }else 
   if(hours >90)
   {
    cout<<" Senior "<<name<<" "<<hours<<" "<<gpa<<endl;
   }
}
Posted
Updated 28-Sep-16 14:42pm
v2
Comments
[no name] 28-Sep-16 14:41pm    
How would we know? We don't know what your program is doing, or not doing, or what your teacher told you when you asked them for help on your homework assignment.
Member 12765182 28-Sep-16 15:15pm    
#include
Richard MacCutchan 28-Sep-16 15:16pm    
Do you seriously believe that is a complete program? I suggest you go back and study your class notes in greater detail.
[no name] 28-Sep-16 15:25pm    
If you think "#include" is your complete program, you need to go back and review your study notes.
Richard MacCutchan 28-Sep-16 15:15pm    
Your program not someone else's.

1 solution

You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.

The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900