Lab 03
Lab 03
Lab 3
1. Introduction to PASS
PASS is the short name of Programming Assignment aSsessment System. In this course, you will
use PASS for program testing and submission.
You may access PASS via the link in Canvas, or directly via https://pass3.cs.cityu.edu.hk
(You’ll be using your CityU EID)
Problems are divided into two types, namely practice and assessment. Assessment problems will
be marked, and you MUST submit your solutions in order to be counted for grading. Practice
problems are for exercise. You can test your solutions of practice problems on the PASS system,
but no submission is required.
To test/submit a solution, click the "Test/Submit" icon for the question you want to solve.
You may specify source code (.cpp file) upload with the "Browse" button (default), or you may
paste the source code into the space provided. (Need to select from radio button)
Note: Your program should follow the input and output format EXACTLY (i.e. identical spacing, new lines and letter
case). Otherwise the PASS system will say that your program's output is incorrect.
To submit for assessment problems, click the Submit button. Again, please be reminded that only
the submissions via the Submit button are counted for grading. The code in Test will NOT be
considered for grading. You are allowed to make multiple submissions to the same problem in the
PASS system. However, please be noted that the TAs will grade and judge late submission based
on your very last submission.
Note: After submission, PASS will report the output of your program versus the "expected output". Note that for
assignments, the test cases for "Test" may not be the same as what we use for grading. (Test cases for "Test",
which you can see when you click the Test button, are usually a subset of the complete test cases we use for
grading.)
Sample problem. The following sample problem is available on PASS to help you get familiar
with the PASS system. You can find it in the problem list as Lab03 Sample, and test your solution
on PASS.
Write a program Area.cpp that the user inputs the width and height of a rectangle. The program
computes and outputs the area of the rectangle. Expected input and output are given as below.
(Note: The underlined words are user input. You don’t need to print it)
1/3
CS2311 Computer Programming 2024-25A
Expected Output:
Please enter the width
3
Please enter the height
5
The area is 3*5=15
2. Problems
NOTE: In all the following problems, the input entered by the user is highlighted by
underline. It is not part of the output from the program.
Write a program that calculates the result of 'a', 'operator', 'b' which are entered by users, like
'1+4 = 5'.
a) Verify whether the input 'a' and 'b' are digits.
b) The operators include +, -, *, /, <, >, =.
c) 'True' is simplified as 'T' while 'False' is simplified as 'F'.
d) When the operator is '=', output '==' instead of '=' and add brackets to the equation, e.g., (1==2)=F.
Expected Output:
Example 1 Example 2
Enter the equation: 1 + 4 Enter the equation: 10 / 6
1+4=5 10/6=1.66667
Example 3 Example 4
Enter the equation: a + 1 Enter the equation: 1 < 4
Invalid input. 1<4=T
Example 5 Example 6
Enter the equation: 1 $ 4 Enter the equation: 5 = 5
Invalid operation. (5==5)=T
2/3
CS2311 Computer Programming 2024-25A
Expected Output:
Example 1 Example 2
Enter the value of A, B and C: Enter the value of A, B and C:
3 3
4 3
5 3
Scalene Equilateral
Example 3 Example 4
Enter the value of A, B and C: Enter the value of A, B and C:
5 1
5 2
2 10
Isosceles Impossible
Example 5 Example 6
Enter the value of A, B and C: Enter the value of A, B and C:
0 1
2 -2
10 10
Impossible Impossible
Hint-1: If you'd like to check for equality, you should not write something like: if (A==B==C), but instead, you
should use the && operator: if (A == B && B ==C)
Hint-2: The order of checking may affect the complexity of your code (although it still works). You may wish to
check for impossible cases first, and identify the scalene case last.
NOTE: Your program MUST follow the EXACT input/output format! Otherwise, you may not pass
the test cases even though your calculation is correct.
3/3