0% found this document useful (0 votes)
60 views1 page

Programming Lab 3: - Control Structures: Selection

The document provides instructions for two programming tasks. Task 1 involves modifying a C++ program that calculates a student's weighted exam score average and assigns a letter grade. Task 2 instructs the user to write a program that takes in a numeric value x and outputs the corresponding y-value of a composite function graph. The user is asked to test their programs with sample inputs to verify they work correctly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views1 page

Programming Lab 3: - Control Structures: Selection

The document provides instructions for two programming tasks. Task 1 involves modifying a C++ program that calculates a student's weighted exam score average and assigns a letter grade. Task 2 instructs the user to write a program that takes in a numeric value x and outputs the corresponding y-value of a composite function graph. The user is asked to test their programs with sample inputs to verify they work correctly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Programming Lab 3 - Control structures: selection

Task 1
Copy the program given below. Save (as grade.cpp), compile and run it.
// Grade calculator
#include <iostream>
using namespace std;
int main() {
int mt1, mt2, fin;
cout << "Enter the three exam scores: ";
cin >> mt1 >> mt2 >> fin;
double avr = 0.3*mt1 + 0.3*mt2 + 0.4*fin;
cout << "The weighted score is " << avr << endl;
string grade;
if (avr < 40. )
grade =
else if (avr >= 40. && avr < 60.) grade =
else if (avr >= 60. && avr < 70.) grade =
else if (avr >= 70. && avr < 80.) grade =
else
grade =

"F";
"D";
"C";
"B";
"A";

cout << "The grade is " << grade << endl;


return 0;
}

a) Verify that the program works correctly.


b) Modify the program with your standard faculty grading scheme.

Task 2
A composite function is shown in the figure below.
Write a program to input a value x and output the evaluated function y = f(x).
Verify that your programs work correctly by testing it with appropriate inputs.

You might also like