• September 25, 2021

PHSARIT

Bring Technology Ideas with you

 Scoring Calculation Sample in C++

A simple calculator can be calculated using a C++ program which is able to add, subtract, multiply and divide, two operands entered by the user. Below code is a scoring calculation sample using C++. The main purpose is to allow users to enter the subjects and the calculation will be made and show pass and fail.

    #include<iostream>
    using namespace std;
    int main() {
    
    	cout << "Welcome to C++ Programming"<<endl;//print welcome message
    	cout << "Good Morning Everyone"<<endl;//print good morning message
    	//cin.get();
    	double math, physic, chemistry, Total, Average;
    	cout << "Subject\t\t\t"<<"Mark\n";
    	cout << "Please enter math\t";
    	cin >> math;
    	cout << "Please enter physic\t";
    	cin >> physic;
    	cout << "Please enter chemistry\t";
    	cin >> chemistry;
    	Total = math + physic + chemistry;
    	cout << "--------------" << endl;
    	cout << "Total Score is:" << Total << endl;
    	Average = Total / 3;
    	cout << "---------" << endl;
    	cout << "You average is:" << Average << endl;
    	if (Average < 50) {
    		cout << "Sorry! You need to retake the exam";
    	}else{
    		cout << "Congradulation! You are pass";
    	}
    	system("pause > 0");
    	//return (0);
    }

    Try out!

    Related post