Assignment 1 Front Sheet
Assignment 1 Front Sheet
Assignment 1 Front Sheet
Student declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that
making a false declaration is a form of malpractice.
Grading grid
P1 P2 P3 M1 M2 D1
Summative Feedback: Resubmission Feedback:
Finally, he needs to know which student has highest grade and lowest grade. Your
program should be menu based with the options above.
When an option is done, the program should go back to the main menu so he can
choose another option. There should be an option to quit program.
The idea of an internally stored program was introduced in the late 1940s by the
Hungarian-born mathematician John von Neumann.
They consist of a CPU (the part that executes instructions), the Memory (the part
where programs and data are stored), the bus (the wire connecting all components), and
the peripherals (input and output devices).
Figure 1
A computer program is a collection of instructions that perform a specific task when executed
by a computer.
Figure 2
Figure 3
Figure 4
1.4.2 Variable
A variable is a symbolic name for (or reference to) information. The variable's name
represents what information the variable contains. They are called variables because the
represented information can change but the processes on the variable remain the same. In
general, a program should be written with "Symbolic" notation, such that a declaration is
always true symbolically.
Local variable
local variable has a limited scope, it's only exist in block which has been declared but when the
block ends, the variable is destroyed and its values are lost.
Figure 5
Global variables
Global variables are useful for values that are relatively constant, or that many functions in
the script must access, such as a session id.
Figure 6
parameter
A parameter is normally a constant in a single simulation, and is changed only when you
need to adjust your model behavior
Figure 7
Sequence
Selection
Iteration
6 statements:
If (…) statement:
Figure 9
Figure 10
Figure 11
Else if (…) statement:
Figure 12
Switch (…) case statement:
Figure 13
1.4.4 Function
A function is a set of statements that take inputs, do some specific computation and
produces output.
Figure 14
Passing a value-type variable to a method by value means passing a copy of the variable to
the method
Figure 15
Figure 16
1.4.7 Modularity.
3.1 Identify Input, Output: variables and data types and its scope.
3.1.1 In/Out variables: take print struct of student
Input:
Output:
Figure 17
Int choice: The choice variable of menu, use int type because choice from 1-6
Input for getting the choice for the table and then run the table base on the input.
Input for getting the number of students from the list, suppose to calculate and run loop.
In max and min:
Use for store the variable of local max and min grade.
Figure 18
Use for saving the value of id and grade when enter from the keyboard.
Figure 19
Use student studentList[] and int n in whole of function for calculate using the information about
student.
Using float max, float min and int count for calculate the local of student have max and min grade.
Highest and lowest for calculate, after that save the local to maxMark and minMark.
3.1.5 Switch-case statement
Input is choice.
Case 3: Use for display a student with ordinal number enter from keyboard.
For calculate
The purpose of the for loop in this case is used to scan the list of students, for each student in list, I also
access the value too.
For display:
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................
.......................................................................................................................................................................