I'm having a problem with the program i did.
The problem is ;
It says that the conversion ( for the grade part , the ones with '+' and '-') may lose it's significant digit.. Does it mean that i can't use the plus symbol or the minus symbol ?? or i need to declare how many characters for grade ? ( char grade [5] ? )
How many nested if's can i do?
And another one is , it says i misplaced the last else .. Um , does it mean that the else if above it needs a curly bracket? Or am I entirely wrong?
I'm using Borland C++ and I'm sorry that it's messy. I started learning computer programming a month ago ; a total newbie. So I'm sorry again and thank you very much.
#include <iostream.h>
#include <conio.h>
int main()
{ int score ;
char grade ;
cout<<"Hello. Please insert your test score. Thank you."<<endl ;
cin>>score ;
if ( score >= 0 && score <= 100 )
{ if( score >= 75 && score <= 100 )
{if (score >= 90 )
grade = 'A+' ;
else if ( score >= 80 && score < 90 )
grade = 'A' ;
else if ( score >= 75 && score < 80 )
grade = 'A-' ;
cout<<"Congratulations. Your grade is "<<grade ;
}
else if ( score >= 60 && score < 75 )
{ if ( score >=70 && score < 75 )
grade = 'B+' ;
else if (score >=65 && score <70)
grade = 'B' ;
else if (score >= 60 && score < 65 )
grade = 'B-' ;
cout<<"Good. Your grade is "<<grade ;
}
else if ( score >= 50 && score , 60 )
{ if (score >=55 && score < 60 )
grade = 'C+' ;
else if (score >= 50 && score < 55 )
grade = 'C' ;
cout<<"Pass. Your grade is "<<grade ;
}
else if ( score >= 40 && score < 50 )
{ if (score >=47 && score < 50 )
grade = 'C-' ;
else if (score >= 44 && score < 47 )
grade = 'D+' ;
else if (score >= 40 && score < 44 )
grade = 'D' ;
cout<<"Sorry, you failed. Your grade is "<<grade ;
}
else if (score >= 30 && score <40 )
grade = 'E' ;
cout<<"Sorry, your result is poor. Your grade is "<<grade ;
else if (score >= 0 && score < 30 )
grade = 'F' ;
cout<<" Sorry , your result is very poor. Your grade is "<<grade<<" . Please try again next semester!" ;
}
else
cout<<"Invalid score. Please try again ! " ;
getch();
return 0 ;
}