You are on page 1of 12

Laboratory Activity 3

EXERCISE No. 1

A student took four quizzes in a term and would like to compute their average. He also would like to know if the average
has a passing mark. Note that the passing mark is 75%.

REQUIREMENTS:

1. Write the corresponding algorithm


a. Narrative
b. Pseudocode
2. Create the equivalent flowchart based on the algorithm of the given problem
Construct the program and record your screen display result

Narrative
Let average=0
Input quiz 1 (q1)
Input quiz 2 (q2
Input quiz 3 (q3)
Input quiz 4 (q4)
Get the scores of 4 quizzes in a
term (q1, q2, q3, q4)
Compute for the average;
average=(q1+q2+q3+q4)/4
If average < 75% = failed
If average >= 75% = passed
Print Average

Pseudocode
Start
Input 4 quizzes scores
Calculate Average of 4 quizzes
If average>=75, Then print Pass
Else print Fail
End
Flowchart
Display result

QUESTIONS:

What statement in the program that determines that the average is passing? “YOU HAVE PASSED AND THIS IS
YOUR PERCENT”, IT LOCATED AT 23RD LINE OF THE PROGRAM

What was the condition applied to satisfy the requirement? IF ELSE CONDITION

What have you observed in using if-else statement in this program? I OBSERVE THAT WHEN USING IF ELSE
STATEMENT, IT’S LIKE YOU’RE ANSWERING A TRUE OR FALSE IN A CONDITION THAT WAS GIVEN.
EXERCISE No. 2
Write a program that will assign grades (A, B, C, D, F) based on marks obtained by a student.

1. Score == 100 ; grade = ‘A’ ; it display the “Superb”


2. Score == 90 ; grade= ‘A’; it display “Excellent”
3. Score >= 80 ; grade =’B’ ; it display “Very Good”
4. Score >=70 ; grade = ‘C’ ; it display “Good”
5. Score > 50 ; grade = ‘D’ ; it display “ Failed”

REQUIREMENTS:

1. Write the corresponding algorithm


a. Narrative
b. Pseudocode
2. Create the equivalent flowchart based on the algorithm of the given problem
3. Construct the program and record your screen display result

Narrative
Start

Input score

Let Score == 100; grade = ‘A’; it displays the “Superb”

Let Score == 90; grade= ‘A’; it displays “Excellent”

Let Score >= 80; grade =’B’; it displays “Very Good”

Let Score >=70; grade =’C; it displays “Good”

Let Score > 50; grade = ‘D’; it displays “Failed”

Display grade

Pseudocode
Start the program

Input the score you got

Let scores equivalent to these grades:

Let Score == 100; grade = ‘A’; it displays the “Superb”

Let Score == 90; grade= ‘A’; it displays “Excellent”

Let Score >= 80; grade =’B’; it displays “Very Good”

Let Score >=70; grade = ‘C‘; it displays “Good”

Let Score > 50; grade = ‘D’; it displays “Failed”

Display the grade and show if it’s “Superb”, “Excellent”, “Very Good”, “Good”, “Failed”.
Flowchart
Display result

What are the data needed for the solution of the program to produce the desired output? THE DATA NEEEDED
ARE THE EQUIVALENT STATEMENT IN THE GIVEN GRADES ABD THE PROPER SYMBOL.

What was the condition applied to satisfy the requirement? IF ELSE IF ELSE CONDITION

What have you observed in using nested if statement in this program? I OBSERVED THAT WHEN YOU’RE
USING THIS CONDITION, YOU CAN ADD ANOTHER CONDITION IN A STATEMENT. IT’S LIKE AN
IMRPROVED VERSION OF IF ELSE STATEMNT
EXERCISE No.3

3. Create an if else program that will check whether an alphabet entered by the user is a vowel or a
constant.

REQUIREMENTS

1. Write the corresponding algorithm


a. Narrative
b. Pseudocode
2. Create the equivalent flowchart based on the algorithm of the given problem
3. Construct the program and record your screen display result

Narrative
Input Alphabet letter
Let lower case vowel=a,e,i,o,u
Let UPPER CASE VOWEL= A,E,I,O,U
If (lowercasevowel||UPPERCASEVOWEL)
Print the letter is a vowel
Else
Print is a consonant
END

Pseudocode
Ask user to input any letter
Let lower case vowel equal to a, e, i, o, u and let
UPPERCASEVOWEL equal to A, E, I, O, U.
If the user input lowercase and UPPERCASE vowel,
Print the letter is a vowel
Else
Print is a consonant
End of the Program.
FLOWCHART
SUPPLEMENTAL ACTIVITIES

1. .Get the value of variable num assuming it is equal to 5.

if (num >= 6)

cout << "Yes";

cout << No;

- No

- The output would be No since the if statement will not be triggered since the number is less than 6. 2. What is the
output of the following code fragment assuming num is 10? if (num == 20) cout << "teenager"; cout << "adult".

- Since no statements will be satisfied thus having no output.

3. After execution of the following code, what is stored in valueNum?

All variables are using data type int. Note that num1=3, num2=5, and num3=7.

if (num2> num3)

if (num1 > num2) valueNum =num2;

else

value Num =num3;

else

if (num2 > num3)

valueNum =num1;

else valueNum = num3


- The first if statement in which num2> num3 will not execute since it is false, so the statement that will execute will be
the else statement in which there are another if statement in which num2> num3, this will also not execute, so the else
statement will make the valueNum = num3 which is 7.

You might also like