You are on page 1of 14

UNIVERSITI TEKNOLOGI MARA

FACULTY OF ARCHITECTURE, PLANNING AND


SURVEYING
CENTER OF STUDIES FOR SURVEYING SCIENCE AND
GEOMATIC

GLS 550 - PROGRAMMING

ASSIGNMENT 1: SELECTION CONTROL

PREPARED BY:

MOHAMMAD SHAHRULNIZAM BIN ISMAIL (2020869758)


MOHD ASHRAF BIN AHMAD ZUBIR (2020612458)
MUHAMMAD RIDZUAN BIN OTHMAN (2017643106)

SUBMITTED TO:
Sr. KHAIRULAZHAR BIN ZAINUDDIN

24 MAY 2021
1. Introduction
 Student in GLS 550 having difficulty on testing their comprehension to this subject.
According to their lecturer, most or few of them are having a lack of understanding
based on topic of Control Selection in this subject. Most students unable to measure
their achievement in the area. So to help with that, we have to develop a programming
which can provide them aid to measure their achievement in their subject so that
students would be motivated to know if they are over achieved or under achieved and
it also will help them in explore more in the topics and areas in subject.

Objective of Works
 To develop a programming using selection control structure to determine
student achievement in GLS 550 course to date.

2. Method Of Solution
a. Analysis
Problem – Find the way for student to determine their achieved
comprehension in programming studies and in the way for student to
get feedback for motivation.
Solution –
a) Prompt the user at the first line “this is to self-test your programming
understanding.”
b) Ask the user either he/she understand how to program using c++
c) Ask the user either he/she understand how to use the selection control
structure. Otherwise, the program need to prompt user to spent more time to
study and practice coding using c++ for better grade.
d) Greeting the user if he/she understand to use selection control structure.
Otherwise, prompt the user to spent more time to learn selection structure.
e) The program should be able to repeat again.

Q1: if understand program enter Y then print out. "Do you understand how to
use the selection control structure?"

else, enter N print "You must spend more time to study and practice coding
using C++ for better result."

2
if Q1 understand. Ask user know the use selection control structure

if understand enter Y then print out thank you for understanding.

else, enter N print "You must spent more time to learn selection structure."

if user want to try again enter Y then the program will continue.

else, enter N then print thank you, Assalamualaikum.

b. Algorithm
Start
Greeting the user
Ask user for their name and matrics number
Print_greeting the user and display their name with matrics number.
ask user either understand program?
IF_Yes, print understand to use selection control structure?
ELSE IF_ No ,print you must spend more time to study and practice coding
using C++ for better result
IF_Yes, print thank you because understand selection control structure
ELSE IF_ No, print user need to spent more time and focus to learn selection
control structure
ask user either want to try again?
IF_ Yes, goto again
ELSE IF_ goto done
End

3
c. FlowChart
START

PROMPT
(Greeting)

INPUT

“Student Names & ID”

PRINT DISPLAY

“Greet User"

PRINT

“Do you understand


Programming?”

If: OUTPUT PRINT


INPUT
YES
“Do you understand to use
“Yes / No “ selection control structure?”

Else if: NO

INPUT
Else if:
“Yes/No”
NO
OUTPUT PRINT If: YES

“You should spent more


time to learn”
OUTPUT PRINT
Else if:
“Thank You for
understanding selection
control structure”

PRINT
YES
“Do you want try again?”

NO

END

Figures 1.

4
D. Inputing The Coding

**************/

#include <iostream> ( call as the header or library file e.g cin & cout )

#include<stdlib.h> ( call as clear screen & must be compare with system (“cls”) )

using namespace std; ( call as global function std )

int main() ( Beginning of function named )

{ ( Input )

start:

system("cls"); ( clear screen )

char start,name[30],question,selection,again; ( Declare the Variable )

int number; ( Declare the Variable )

( Declare the statement & Condition )

cout << "Assalamualaikum, Hope you having a great day today !";

cout << "\nPlease Enter Your Name : "; ( cout : for display the output on the computer screen)

cin >> name; ( cin :For input of the output to make the system
works)

cout << "\nPlease Enter Your Matric Number : ";

cin >> number;

cout << "\nHai, "<<name;

cout << "\nYour student ID is : " <<number<<endl;

cout << "Welcome to GLS550 course!"<<endl;

cout << "\n*** This program is for self-test your programming understanding ! ***"<<endl;

cout << "Please enter 'Y' for **YES** and 'N' for **NO** for each question that will be ask!"<<endl;

cout << "\n 1. Do you understand to program using C++? : ";

cin >>question;

if (question=='y'||question=='Y')

cout << "GOOD! You understand to program using C++ !!";

else if (question=='n'||question=='N')

5
cout << "That's NOT GOOD! You must spend more time to study and practice coding using C++ for better
result";

else

cout<<"\nYOU ENTER WRONG KEY!";

cout << "\n 2. Do understand how to use the selection control structure? : ";

cin >> selection;

if(selection=='y'||selection=='Y')

cout << "That's GOOD! You understand to use selection control structure !!";

else if (selection=='n'||selection=='N')

cout << "That's NOT GOOD! You need to spent more time and focus to learn selection control structure !!";

else

cout <<"\nYOU HAVE ENTER THE WRONG KEY !!";

cout <<"\n\nYou want to try again?";

cin>>again;

if(again=='y'||again=='Y')goto start; ( Go back to the start variable)

else if (again=='n'||again=='N')goto done; ( Go to the done variable )

done:

cout<<"\nThank You and Sorry for taking your time,Assalamualaikum ";

6
3. Result
Coding in C++

(Figures 2)

This is the result when the user understand all the question that had been asked.

(Figures 3)

7
This is when the user didn’t understand the first question that been asked.

Figure 4

This is the result when the user didn’t understand 2nd of the question that been asked.

Figure 5

This is when the user accidentally type the wrong key for the answer of the question.

8
Figure 6

a) Full Coding Result attached in Appendix A.

4. Disscussion & Conclusion


a) Conclusion
For Conclusion, as the task given to develop a program that will help student to
determine their achievement in comprehending topics in GLS 550. Positively
resultant of task. We able to produce the program demanded and following the
standards and specifications given by question. The program able to run smoothy
without major issue. After many testing and debugging we will able to produce
the result. Furthermore, with use of selection control in our program. We able to
provide alternate answers to students based on their input in the program. We also
make it more user-friendly so that it is understandable and easy to use for any
user intended.

5. References
 Introduction to Programming (GLS 550), Chapter 4

9
 Exercise of week 6 with Sir KhairulAzhar
- Exercise 2 Selecting Manifying (Nested If)
- Exercise 3 Switch Function ( Switch Statement)

APPENDIX A
/***************

10
Title : Assignment 1

Programmer : Ashraf, Shahrul, Ridzuan

Submit Date : 24/05/2021

Question: Develop a program using selection control structure to determine student achievement in GLS550 course to date.

The program should have:

- Prompt the user at the first line “this is to self-test your programming understanding”.

- Ask the user either he/she understand how to program using c++

- Ask the user either he/she understand how to use the selection control structure. Otherwise, the program need to prompt
user to spent more time to study and practice coding using c++ for better grade.

- Greeting the user if he/she understand to use selection control structure. Otherwise, prompt the user to spent more time to
learn selection structure.

- The program should be able to repeat again.

Analysis :

Q1: if understand program enter Y then print out. "Do you understand how to use the selection control structure?"

else, enter N print "You must spend more time to study and practice coding using C++ for better result."

if Q1 understand. Ask user know the use selection control structure

if understand enter Y then print out thank you for understanding.

else, enter N print "You must spent more time to learn selection structure."

if user want to try again enter Y then the program will continue.

else, enter N then print thank you

2. Algorithm:

Start

11
Greeting the user

Ask user for their name and matrics number

print greeting the user and display their name with matrics number.

ask user either understand program?

if yes print understand to use selection control structure?

else if no print you must spend more time to study and practice coding using C++ for better result

if yes print thank you because understand selection control structure

else if no print user need to spent more time and focus to learn selection control structure

ask user either want to try again?

if yes goto again

else if goto done

End

3. Coding

4. Testing & Debugging

5. Documentation

CODING

**************/

12
#include <iostream>

#include<stdlib.h>

using namespace std;

int main()

start:

system("cls");

char start,name[30],question,selection,again;

int number;

cout << "Assalamualaikum, Hope you having a great day today !";

cout << "\nPlease Enter Your Name : ";

cin >> name;

cout << "\nPlease Enter Your Matric Number : ";

cin >> number;

cout << "\nHai, "<<name;

cout << "\nYour student ID is : " <<number<<endl;

cout << "Welcome to GLS550 course!"<<endl;

cout << "\n*** This program is for self-test your programming understanding ! ***"<<endl;

cout << "Please enter 'Y' for **YES** and 'N' for **NO** for each question that will be ask!"<<endl;

cout << "\n 1. Do you understand to program using C++? : ";

cin >>question;

if (question=='y'||question=='Y')

cout << "GOOD! You understand to program using C++ !!";

else if (question=='n'||question=='N')

13
cout << "That's NOT GOOD! You must spend more time to study and practice coding using C++ for better
result";

else

cout<<"\nYOU ENTER WRONG KEY!";

cout << "\n 2. Do understand how to use the selection control structure? : ";

cin >> selection;

if(selection=='y'||selection=='Y')

cout << "That's GOOD! You understand to use selection control structure !!";

else if (selection=='n'||selection=='N')

cout << "That's NOT GOOD! You need to spent more time and focus to learn selection control structure !!";

else

cout <<"\nYOU HAVE ENTER THE WRONG KEY !!";

cout <<"\n\nYou want to try again?";

cin>>again;

if(again=='y'||again=='Y')goto start;

else if (again=='n'||again=='N')goto done;

done:

cout<<"\nThank You and Sorry for taking your time,Assalamualaikum ";

14

You might also like