0% found this document useful (0 votes)
25 views3 pages

PUA Assign2.1 NestedIf

The document is an assignment for a Computer Programming course at the Technological Institute of the Philippines, requiring students to create a C++ program that uses nested switch-case conditions to determine a student's year level and status. Students must input their year level and status, and the program will output the corresponding results based on predefined conditions. Additionally, students are required to submit their source code and screenshots of the program's output, along with a pledge of originality.

Uploaded by

qljbpua
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)
25 views3 pages

PUA Assign2.1 NestedIf

The document is an assignment for a Computer Programming course at the Technological Institute of the Philippines, requiring students to create a C++ program that uses nested switch-case conditions to determine a student's year level and status. Students must input their year level and status, and the program will output the corresponding results based on predefined conditions. Additionally, students are required to submit their source code and screenshots of the program's output, along with a pledge of originality.

Uploaded by

qljbpua
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/ 3

TECHNOLOGICAL INSTITUTE OF THE PHILIPPINES

QUEZON CITY
ITE001 – Computer Programming 1
NAME: Pua, Lorenz Jacob B.
PROGRAM/SECTION: ITE001 / CE21S7
ASSESSMENT TASK: Selection Control Structure using Nested Switch Case Condition
if () Condition

The following question support the attainment of Course Intended Learning Outcomes (CILO): Design
computing-based solution using control structures, functions, array and other statements.

INSTRUCTION: Read and study the assignment below. Solve the problem using C++ programming
language, compile, run and screenshot the correct output. Copy and paste the source code or program
code and the required sample output (screenshot) in the format below. The output should also display the
school name, course name, student name, program, section, date and title of the assessment task.

PROBLEM: Write a program that will let the user to input year level and status based on the table below. The
output should be based on the possible combination of year level and status.

YEAR LEVEL STATUS


INPUT OUTPUT INPUT OUTPUT
1 First Year R or r Regular
2 Second Year I or i Irregular
3 Third Year other letters Invalid
4 Fourth Year
other
Invalid
number
Sample Output
NAME:
SECTION:

Enter Year Level : 1


Enter Status :r
The student is First Year and Regular

Enter Year Level : 2


Enter Status :I
The student is Second Year and Irregular

Enter Year Level : 4


Enter Status :s
The student is Fourth Year and Invalid
ANSWER:

1. SOURCE CODE: Write or paste the program code below

#include <iostream>
#include <string>
using namespace std;

int main() {
int yearLev;
char status;
string name, section;

cout << "Name: ";


getline(cin, name);

cout << "Section: ";


getline(cin, section);

cout << "\nEnter Year Level: ";


cin >> yearLev;

cout << "\nEnter Status: ";


cin >> status;

cout << "The student is ";

switch (yearLev) {
case 1: cout << "First Year";
break;
case 2: cout << "Second Year";
break;
case 3: cout << "Third Year";
break;
case 4: cout << "Fourth Year";
default: cout << "Invalid Year Level";
break;
}

if ((yearLev >= 1 && yearLev <= 4)) {


if (status == 'R' || status == 'r') {
cout << " and Regular" << endl;
} else if (status == 'I' || status == 'i') {
cout << " and Irregular" << endl;
} else {
cout << " and Invalid" << endl;
}

return 0;
}

2. OUTPUT: Show two(2) sample outputs - one combination of year level and status and one showing an
invalid combination.

Year level and Status:

Invalid Combination:

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