0% found this document useful (0 votes)
7 views

Lab Act2 CPP

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)
7 views

Lab Act2 CPP

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/ 4

TECHNOLOGICAL INSTITUTE OF THE PHILIPPINES

COLLEGE OF COMPUTER STUDIES


938 Aurora Boulevard, Cubao, Quezon City

ITE 001

2023 Semester SY: 2024


Prelims Period
Laboratory Activity # 2

Name: Zjan Gabriel G. Molleda Program: IT


Section: IT11S10 Instructor: Prof. Allan Ong

Activity 2
-Basic programming using C++ Input/ Output (cin/cout object)
 The following question supports the attainment of Course Intended Learning Outcomes (CILO): Identify the components, features,
characteristics, and uses of C++ Language in various applications; and Design computing-based solution using control structures,
functions, arrays and other statements.

Instruction: Write a program that will let the user enter: Student Name, FOUR course Code, FOUR course Units and FOUR course Grade.
The program will compute and display the student's General Weighted Average(GWA).

Variables: studName, cCode1, cCode2, cCode3, cCode4, cUnit1, cUnit2, cUnit3, cUnit4, cGrade1, cGrade2, cGrade3, cGrade4, totUnits,
gwa=0.

Formula:
totUnits=cUnit1 + cUnit2 + cUnit3 + cUnit4
gwa= ((cGrade1*cUnits1)+( cGrade2*cUnits2) + ( cGrade3*cUnits3) +( cGrade4*cUnits4))/ totUnits

************************************************************************************************************************************************************

SAMPLE OUTPUT:
Name: Great Allan Ong
Section: IT11S10

Enter student name: Great Allan Ong


Enter course code 1: ITE001
Enter course grade 1: 95
Enter course unit 1: 3

Enter course code 2: ITE011


Enter course grade 2: 97
Enter course unit 2: 3

Enter course code 3: PE001


Enter course grade 3: 90
Enter course unit 3: 2

Enter course code 4: GEC004


Enter course grade 4: 92
Enter course unit 4: 3
Student Name: Great Allan Ong

COURSES Units Grade


ITE001 3 95
ITE011 3 97
PE001 2 90
GEC004 3 92

General Weighted Average(GWA) = 93

Source Code: paste the source code here

#include<iostream>
#include<string>

using namespace std;


int main()
{
string studName;
string cCode1;
string cCode2;
string cCode3;
string cCode4;
int cUnit1;
int cUnit2;
int cUnit3;
int cUnit4;
int cGrade1;
int cGrade2;
int cGrade3;
int cGrade4;
int totUnits;
int gwa=0;

cout<<"Enter student name: ";


getline(cin, studName);
cout<<"Enter course code 1: ";
cin >> cCode1;
cout<<"Enter course grade 1: ";
cin >> cGrade1;
cout<<"Enter course unit 1: ";
cin >> cUnit1;
cout<<endl;

cout<<"Enter course code 2: ";


cin >> cCode2;
cout<<"Enter course grade 2: ";
cin >> cGrade2;
cout<<"Enter course unit 2: ";
cin >> cUnit2;
cout<<endl;

cout<<"Enter course code 3: ";


cin >> cCode3;
cout<<"Enter course grade 3: ";
cin >> cGrade3;
cout<<"Enter course unit 3: ";
cin >> cUnit3;
cout<<endl;

cout<<"Enter course code 4: ";


cin >> cCode4;
cout<<"Enter course grade 4: ";
cin >> cGrade4;
cout<<"Enter course unit 4: ";
cin >> cUnit4;
cout<<endl;

totUnits=cUnit1 + cUnit2 + cUnit3 + cUnit4;


gwa = ((cGrade1*cUnit1)+( cGrade2*cUnit2) + ( cGrade3*cUnit3) +( cGrade4*cUnit4))/ totUnits;

cout<<"Student name: "<<studName<<endl<<endl;


cout<<"Course"<<" "<<"Grade"<<" "<<"Unit"<<endl;
cout<<cCode1<<""<<cGrade1<<" "<<cUnit1<<endl;
cout<<cCode2<<""<<cGrade2<<" "<<cUnit2<<endl;
cout<<cCode3<<""<<cGrade3<<" "<<cUnit3<<endl;
cout<<cCode4<<""<<cGrade4<<" "<<cUnit4<<endl;
cout<<endl;
cout<<"Total Units: "<<totUnits<<endl;
cout<<"(GWA): "<<gwa;

OUTPUT: paste the output here...PRESS ALT PRINT SCREEN TO SCREEN SHOT THE OUTPUT
Honor Pledge
"I affirm that I have not given or received any unauthorized help on this assignment and that this work is my own".

You might also like