Answer to Question #41484 in Prolog for ahmed

Question #41484
write a prolog code that accepts input of CGPA from user and determine the level of that CGPA
1
Expert's answer
2014-05-14T10:08:35-0400
#include <iostream>
char determineGrade (double CGPA) {
if ( CGPA <= 100 && CGPA >= 90 ) {
return 'A';
}
if ( CGPA >=80 && CGPA <=89 ) {
return 'B';
}
if ( CGPA >= 70 && CGPA <= 88 ) {
return 'C';
}
if ( CGPA >=65 && CGPA <= 69 ) {
return 'D';
}
if ( CGPA <= 64 ) {
return 'F';
}
}
int main() {
double CGPA = 0;
std::cout << "Please input the CGPA in percentage." << std::endl;
std::cin >> CGPA;
while ( CGPA < 0 || CGPA > 100 ) {
std::cout << "Acceptable values are from 0 till 100" << std::endl;
std::cin >> CGPA;
}
std::cout << "Your grade is " << determineGrade(CGPA) << std::endl;
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS