Tuesday 13 November 2018

Lab3


For Lab 3,the topics are Problem Solving, Data Types, Selection and the learning outcome are:
1. Trace a program.
2. Designing solution to a problem using Problem Analysis Chart (PAC), Input Process Output Chart (IPO) and Flowchart.
3. Declare, initialize and use appropriate data types in a program.
4. Use selection statement to specify alternative paths of program’s execution.
5. To write, compile and run a simple computer program based on the flowchart.
For the first part if the lab,we were given few questions on source code and we need to trace the program to identify the input,variable,and also the expected output.Throughout the lab we are able to do the tracing part because we are used to the to the tracing program problems.



Line
variable
output
5
Int number

7
Int number
Number is even
8
Int number
Number is odd

The Table above shows one of the tracing that have been done in the Lab


Designing solution to a problem using Problem Analysis Chart (PAC), Input Process Output Chart (IPO) and Flowchart is when we are given the question to run a program.We need to follow the procedure in order for us to be able to write or run a java program.First we need to do the Problem Analysis Chart,then Input Process Output Chart and also flowchart where there will be algorithm found in order for us to build the source code for the program.
Declare, initialize and use appropriate data types in a program
There are actually many data types that are avaible that is,int,float,double ,long ,short,byte,Boolean,char.We declared it in order for the program to easy to generate the output.

Use selection statement to specify alternative paths of program’s execution,we in this case use the if else statement,where the program will ask for the input from the user,and it will follow certain condition that have been assigned to the number.



To write, compile and run a simple computer program based on the flowchart.Lastly, we were given problems where we need to solve the problem and write the program in java.



\


Problem where we need to exchange from rm to usd and usd to rm.

No comments:

Post a Comment