Professional Documents
Culture Documents
LAB03
LAB03
LAB: 03
General notes:
• Each exercise is a separate project and should be saved in a different folder. The name of the
• Write your name, ID, and PC number as a comment on the main class.
• Zip your folders into one folder and upload your answer to the blackboard before the end of
palindrome means a word, phrase, or sequence that can be read the same backwards as forward,
so it well be the same sequence after reverse e.g. 123454321 , 9876789 , mom, ABCBA. Your
program have to check if array elements are palindrome.
Balanced Parenthesis or valid Parenthesis occur when all the parenthesis match up correctly and
each open parenthesis '(' is closed by ')' , as shown in the following example: x*((x+x)-y). But in
case open parenthesis are more than close parenthesis or vice versa then parenthesis are not balanced
e.g. x+((y-z) , (x-z))+y . Your program should check if the parenthesis are balanced in an array of
characters.
2
• The method should calculate number of parenthesis, use counter to keep tracking number
of parenthesis, so increment the counter if character is '('. But if the character is the
closing ')' decrement the counter
▪ if a[index]==’(‘ then counter incremented
▪ if a[index]==’)‘ then counter decremented
• The method should return number of parenthesis in the array, if the number=0 then array
is balanced, otherwise array is not balanced
▪ if the counter==0 this means all open Parenthesis are closed
▪ if the counter>0 this means open Parenthesis are more than close Parenthesis
▪ if the counter<0 this means close Parenthesis are more than open Parenthesis
Data:
• Name (string)
• ID (integer)
• Level (integer)
• GPA (double)
Methods:
• Get and set for each data item
• Print all students
• Main Method:
o Create an array of 4 students then assign values for each student (no need to read
information from user).
o Compute the GPA sum of all students using method BinarySum
o Compute the average GPA of all students