פתרון
/*
Module: tr3_q1.cpp
Author: Yariv Amar
What? This program prints the status of a student upon 3 marks.
Input : 3 marks, (integer 0-100) sepereted by spaces or enter
Output: student's status.
Assumptions on input: Valid
How?
using "if" nesting upon the conditions of the question.
*/
#include <iostream.h>
void main()
{
int Mark1 , Mark2 , Mark3; //Declering on student's marks.
const int MAX = 100;
const int EXELENT = 95;
const int PASS = 60;
//step 1:getting the marks
cout<<"Please enter 3 mark of the student seperated by spaces or
enter:\n";
cout<<"----------------------------------------------------------------\n";
cin>>Mark1>>Mark2>>Mark3;
//step 2: checking the marks and printing the status
if //fail all or (fail 2 and one is 60) -> kick out
(Mark1<PASS && Mark2<PASS && Mark3<PASS ||
Mark1<PASS && Mark2<PASS && Mark3==PASS ||
Mark1<PASS && Mark3<PASS && Mark2==PASS ||
Mark2<PASS && Mark3<PASS && Mark1==PASS)
cout<<"The sutdent is kicked out!\n";
else
if //only one higher than 60 -> stays A
(Mark1>PASS && Mark2<=PASS && Mark3<=PASS ||
Mark2>PASS && Mark1<=PASS && Mark3<=PASS ||
Mark3>PASS && Mark1<=PASS && Mark2<=PASS)
cout<<"The sutdent stays another year in grade A\n";
else
if //at least one=100 and the others at least 95 ->Excelent jump to C
((Mark1==MAX || Mark2==MAX || Mark3==MAX) &&
Mark1+Mark2+Mark3>=MAX + 2*EXELENT)
cout<<"EXCELENT! The sutdent is jumped to grade C\n";
else //pass at least 2 and NOT excelent -> continu to B
cout<<"The sutdent allowed to continue to grade B\n";
}
פלטים מיצגים
פלט לדוגמה:
Please enter 3 mark of the student seperated by spaces or enter:
----------------------------------------------------------------
60 21 59
The sutdent is kicked out!
פלט לדוגמה:
Please enter 3 mark of the student seperated by spaces or enter:
----------------------------------------------------------------
60 60 80
The sutdent stays another year in grade A
פלט לדוגמה:
Please enter 3 mark of the student seperated by spaces or enter:
----------------------------------------------------------------
90 70 85
The sutdent allowed to continue to grade B
פלט לדוגמה:
Please enter 3 mark of the student seperated by spaces or enter:
----------------------------------------------------------------
100 96 95
EXCELENT! The sutdent is jumped to grade C