Program
Create a program that asks for the student's score and the number of items in a laboratory exercise. It will then compute for the grade using the formula.
Input
The user is required to enter two (2) inputs where the first input is the student score and the second one is the total number of items.
Output
The program will display the solution or formula (Score / Total # of Items) x 60 + 40 followed by an equal sign then the equivalent laboratory grade with two decimal places of the student. (Refer to the sample output)
++++++++++++++++++++++++++++++
Sample Input #1
15 20
Sample Output #1
(15/20)x60+40=85.00
++++++++++++++++++++++++++++++
Sample Input #2
21 40
Sample Output #2
(21/40)x60+40=71.50
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int score;
int totalItems;
cin>>score>>totalItems;
float grade=((float)score / (float)totalItems) * 60 + 40;
cout<<fixed<<"("<<score<<"/"<<totalItems<<")x60+40="<<setprecision(2)<<grade<<"\n";
cin>>score;
return 0;
}
Comments
Leave a comment