CS1315 Computer Programming
Computer Programming
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
CS1315 Computer Programming
Assignment One (2023-24 Sem. A)
Deadline: 25-Oct-2023 23:59 (Week 8 Wed) No Late submission will be accepted
Problem description
Given a piece of paper with dimension W x H, you need to create a top-less box from
it by cutting and folding along lines which are parallel to the edges (i.e. no rotation).
In this assignment, you will write a program to find out the maximum volume of the
created box. Usually the problem could be solved by calculus, however there are some
extra complexities here:
The width, height and length of the created box must be integers.
The width, height and length must be different values.
It is okay for not using up the whole piece of paper (by cutting along lines parallel
to the edges) .
The program will first read in two integers for W and H. (The input is always integer
and will not be other types like string. No error checking is needed). If the input
numbers are not within range [10..3000], the program should print “Invalid input
range.” and read again until the numbers are in range.
The program will then output:
The dimension of the created box (in descending order of edge length)
The volume of the created box (with comma (,) for every 3 digits)
The surface area to volume ratio in 3 decimal places
(Note that “surface area” counts only 5 faces as the box is top-less)
For boxes with the same volume (e.g. 6x4x2 and 8x3x2), consider only the one with a
larger surface area to volume ratio.
Sample Input / Output:
Example 1: (User Input is underlined)
Input paper dimension: 10 10
Box dimension: 6 x 5 x 2
Volume: 60
Surface to Volume ratio: 1.233
Example 2: (User Input is underlined)
Input paper dimension: 10 5
Invalid input range.
Input paper dimension: 3001 3
Invalid input range.
Input paper dimension: 10 11
Box dimension: 7 x 6 x 2
Volume: 84
Surface to Volume ratio: 1.119
Example 3: (User Input is underlined)
Input paper dimension: 10 3000
Box dimension: 2996 x 6 x 2
Volume: 35,952
Surface to Volume ratio: 0.834
Example 4: (User Input is underlined)
Input paper dimension: 789 456
Box dimension: 603 x 270 x 93
Volume: 15,141,330
Surface to Volume ratio: 0.021
Marking criteria
Submitted program will be tested repeatedly with PASS. Marks will be graded objectively
based on the number of correct outputs reported by PASS.
If the program is not compilable in PASS, zero mark will be given.
(even though it may works in the compiler that you’re using)
Make sure that the output format (spelling, punctuations, spacing…etc) follows exactly the
sample output above otherwise PASS will consider your answer incorrect. Note that the
marker will make NO manual attempt to check or re-mark program output.
Unlike tutorial exercises, for assignment, PASS will NOT make ALL test cases visible. (i.e. there
are hidden test cases). Queries regarding hidden test case(s) will not be answered. It is the
responsibility of a programmer to design own test cases in order to verify the correctness of
the written program.
Note that the marking in PASS is automatic, therefore the following situations may lead to
zero marks:
Input/output does not match the requirements as defined.
(e.g. incorrect spacing, incorrect spelling, letter cases or punctuations)
Submission of non .cpp files (e.g. .exe or .zip files)
Not uploading via “Submit” function. (Note: Upload via “Test” button will not be counted)
(Students may test or submit many times, only the last “submit” will be marked)
Please also note that the PASS plagiarism check will also be turned on. The same disciplinary
action will be applied without distinguishing which one is the source / copier. Please
safeguard your files if you work on your assignment using public computers (e.g. CityU Lab)
Testing and Submission
Students should submit cpp file to PASS before the deadline. No other submission method
(e.g. hardcopy, email…etc) is accepted. Students may use whatever IDE/compiler for
development, but program which is not compilable in PASS will lead to zero mark (e.g.
program using non-standard, platform-specific features). The marker will make no attempt to
fix the syntax error and make the code compilable.
If you observe that the answer in PASS is different from the one you get in your PC, most
likely it is caused by programming bugs like uninitialized variables. The result by PASS will be
used for marking without consideration of what you observe in your local PC.
Please also note that the PASS system could be extremely busy and may become sluggish in
responding near deadline. You’re suggested to reserve enough time for submission (Not the
usual button, but the “Submit” button for assignments).
To protect yourself, it is advised that you write down your particulars (full name, student
number, eid…) in the beginning of your source code as comment.