Basic Programming Using C++ Input/ Output (Cin/cout Object)
Basic Programming Using C++ Input/ Output (Cin/cout Object)
QUEZON CITY
COLLEGE OF INFORMATION TECHNOLOGY EDUCATION (CITE)
ITE001- Computer Programming 1
NAME:
PROGRAM/SECTION:
ASSESSMENT TASK: 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, array and other statements.
Instruction: Write a program that will let the user to enter: Student Name, two Subject Code, two Subject
Units and two Subject Grade. The program will compute and display the student General Weighted
Average(GWA).
Filename: SurnamePrelimActivity2.cpp
Variables: studName, cCode1, cCode2, cUnit1, cUnit2, cGrade1, cGrade2, totUnits, gwa=0.
Formula: totUnits=sUnit1 + sUnit2
gwa= ((cGrade1*cUnits1)+( cGrade2*cUnits2))/ totUnits
SAMPLE OUTPUT
Enter student name: Jasmin
Enter course code 1: ITE 001
Enter course grade 1: 95
Enter course unit 1: 4
Enter course code 2: ITE011
Enter course grade 2: 97
Enter course unit 2: 3
#include <iostream>
using namespace std;
int main(){
char studName[30];
int cGrade1, cGrade2, cUnit1, cUnit2, totUnits;
string cCode1, cCode2;
int gwa = 0;
cout<<("Enter Student Name:");
cin.getline(studName,30);
getline(cin, cCode2);
cout<<("Enter Course Grade 2:");
cin>>cGrade2;
totUnits=cUnit1 + cUnit2;
cout<<endl;
cout<<"Student Name: "<<studName<<endl;
totUnits=cUnit1 + cUnit2;
gwa=((cGrade1*cUnit1)+(cGrade2*cUnit2))/totUnits;
cout<<endl<<"General Weighted Average (GWA)=" <<gwa<<endl;
}