Académique Documents
Professionnel Documents
Culture Documents
EDP 101/L
Computer Programming Fundamentals
Laboratory Exercise # 3
Conditional Statements
if /else if
Student Name
(LN, FN MI)
Subject Teacher
Date Submitted
Score
Laboratory Exercise # 3
CONDITIONAL STATEMENTS
If/else if
Objectives:
Materials:
1 computer set
C++ IDE
Introduction:
Relational Operators
Relational operators are used when dealing with comparison of
numeric and character values. Shown in Table 3.1 are the different
symbols and descriptions of each relational operator.
Symbol Description
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to
== Equal to
!= Not equal to
Table 3.1 Relational Operators
if (expression)
statement;
#include <iostream>
using namespace std;
int main()
{
float average;
Two-way Selection
Syntax:
if (expression)
statement;
else
statement;
if (condition1)
statement/s;
else if (condition2)
statement/s;
else if (condition3)
statement/s;
else
statement/s;
= if the bonus is less than $1,000, we set up a tent and eat steak in the
back yard
= if the bonus is less than $10,000 and greater than or equal to $1,000,
we go to Disney World
= if the bonus is $10,000, we go to Hawaii
We could code this using if/else if/else statement as follows:
Logical Operators
Operator Description
&& AND
|| OR
! NOT
Expression Evaluation
(x <= z) || (y == z) FALSE
(x <= z) || (y != x) TRUE
Laboratory Task:
Program Requirements:
1. The program will ask the user to input scores for examinations,
quizzes, laboratory exercises and laboratory project. Please refer
to figure 3.1 (sample screen display).
2. It shall only accept inputs ranging from 0 - 100.
3. A Base-15 grading system shall be used to compute the grades.
(raw score / no. of items) * 85 + 15;
4. Please refer to figure 3.2 for the assigned weights of each
activity.
5. After keying in all inputs, the Final Grade and Remarks will be
shown.
6. The program will allow to key in another set of inputs if an <Enter
Key> is pressed and exit for any other key (use ASCII code of
Enter Key, 13).
7. Display the remarks as output on the following given scale.
Please refer to figure 3.3.
Computation of Grades
Final 30%
100 – 95 Excellent
94 - 90 Very Good
89 - 85 Good
84 – 80 Satisfactory
79 – 75 Fair
Below 75 Failed
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
________________________________________________________
Scoring Rubrics
Ratings
Parameters
3 2 1
Specifications Source code contains Source code lacks Source code is not
(30%) the complete details to necessary details to enough to run the
run the program run the program program correctly.
correctly. correctly.
(30) (20) (10)
Screen Output Source code is well Source code allows Source code does
(10%) organized and easy to the required screen not meet the
understand. output to be required screen
displayed correctly output to be
with 1-3 errors displayed correctly.
found.
(10) (6) (3)