0% found this document useful (0 votes)
2 views3 pages

Lab 03

Lab 3 of CS2311 Computer Programming introduces the Programming Assignment Assessment System (PASS) for testing and submitting programming assignments. Students must submit solutions for assessment problems to be graded, while practice problems can be tested without submission. The document provides specific programming tasks, including calculating equations and determining triangle types, along with expected input/output formats and hints for implementation.

Uploaded by

chuigary70866
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Lab 03

Lab 3 of CS2311 Computer Programming introduces the Programming Assignment Assessment System (PASS) for testing and submitting programming assignments. Students must submit solutions for assessment problems to be graded, while practice problems can be tested without submission. The document provides specific programming tasks, including calculating equations and determining triangle types, along with expected input/output formats and hints for implementation.

Uploaded by

chuigary70866
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CS2311 Computer Programming 2024-25A

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)

Select our course – CS2311_YF(2223 Sem.A) - Computer Programming

To access problems, click the link "Problem list".

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)

To test the program (practice or assignment), click the Test 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.

Q1. [For Assessment. Will Be Marked.]


You must click submit to submit your solution. Deadline is 24 hrs after the end time of your lab
session.

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

Hint: Try to use switch .. case.

Q2. [For Practice]


Write a program that reads 3 integer values (> 0) from the user. The 3 values are interpreted
as representing the lengths of the three sides of a triangle. The program prints a message
saying whether the triangle is Equilateral (all sides equal), Isosceles (only 2 sides equal),
Scalene (all sides unequal), or Impossible (can't form a triangle). A triangle can be formed
only if the sum of the length of any 2 sides is greater than the length of the 3rd side and the
length of all the sides of the triangle are positive.

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

You might also like