Professional Documents
Culture Documents
Csci 151 Pa1
Csci 151 Pa1
Programming Assignment 1
Deadline: THURSDAY, 29 SEPTEMBER 2022 by 20:00
This programming assignment is based on the contents of Lessons 1–11 inclusive. You
will need to submit on Moodle your program with .c extension as explained in the rules
below.
Rules
1. Late submissions will NOT be accepted. A 0 grade will be given for late
submissions.
2. No deadline extensions will be granted.
3. The assignment will be graded according to the following rubric:
○ 10% if there is a reasonable attempt to address the tasks;
○ 20% in total for: correct indentation (5%), appropriate comments (5%),
successful compilation (10%).
○ 70% in total for the three tasks, partitioned in the way indicated in the task
descriptions.
Please note that if compilation and/or execution problems cannot be easily
fixed during grading, you will lose the entire 70% grade component of the
three tasks.
4. Your code must be developed individually. You cannot collaborate with your
peers. You cannot post your code on any public repository, nor can you share it
with anybody. Any violations to this code of conduct will be treated as academic
misconduct.
5. Check your code with the online compiler
https://www.programiz.com/c-programming/online-compiler/ before submitting it to
make sure it compiles. However, even if you get the expected results from the
online compiler, this does not guarantee that your code is correct (you can only
claim that your program compiles, not that it is correct).
6. Submitted code will be automatically checked using tools that detect plagiarism.
7. In case cheating is detected, the grade of this assignment will be zero and a
further penalty of 10 points will be applied to the total course grade (you would
lose 25% of your course grade!).
8. You may be asked to explain your code and rewrite some parts of it in front of the
instructors.
9. Please note that
○ The only library you can use is <stdio.h>
○ You cannot use arrays, pointers, function definitions or anything that is
presented in the course after lesson 11.
10. Submit the tasks in 3 different C files named
Yourfirstname_Yourlastname_TaskN.c where N is either 1, 2, or 3. Make sure to
include the underscore ‘_’ in the filename.
11. In order to be accepted, your submission
○ must be of text format with a ‘.c’ extension (no Word or other formats and
no archives will be accepted), correctly named as explained in Rule 10.
○ You will receive a zero grade if you do not submit the assignment or you
do not adhere to this rule!
Task 1 (20%):
You will write a program that will simulate the rock, paper, scissors game.
Here are the steps you need to implement in your program:
● Ask Player 1 to enter his/her choice. Player 1 will enter characters ‘R’,’P’, or ‘S’
for rock, paper, or scissors, respectively.
● Ask Player 2 to enter his/her choice. Player 2 will enter characters ‘R’,’P’, or ‘S’
for rock, paper, or scissors, respectively.
● If Player 1 or Player 2 enters any other character, your program should output
“Not a valid input!”, and keeps asking the user to enter a valid input.
● In case Player 2 enters the same input as Player 1, your program will ask Player
2 to enter his/her input again until it’s different from Player 1.
● Based on both players' selection, your program will output the winning player,
i.e., either of the following messages will be printed “Player 1 wins”, or “Player 2
wins”.
● Your program will ask the user if he/she wants to play again. In case the user
enters ‘Y’ or ‘y’ the program will start over. If the user enters any other character
the program will stop.
Sample run (Bold font indicates user inputs):
Enter Player 1 choice ('R','P','S')
R
Enter Player 2 choice ('R','P','S')
S
Player 1 wins!
Do you want to play again?(Enter 'Y' or 'y' for YES)
y
Enter Player 1 choice ('R','P','S')
P
Enter Player 2 choice ('R','P','S')
X
Not a valid input!
Enter Player 2 choice ('R','P','S')
S
Player 2 wins!
Do you want to play again?(Enter 'Y' or 'y' for YES)
Y
Enter Player 1 choice ('R','P','S')
S
Enter Player 2 choice ('R','P','S')
S
Your input is the same as Player 1. Please select another choice
Enter Player 2 choice ('R','P','S')
R
Player 2 wins!
Do you want to play again?(Enter 'Y' or 'y' for YES)
n
Task 2 (25%):
In this task, you are asked to write a program that determines the day of the week on
which a given date falls using the following algorithm.
The value of I is the day of the week, where 0 represents Sunday, 1 represents Monday,
. . , and 6 represents Saturday. In case the computed value of I is negative, add 7 to get
a non negative number between 0 and 6.
Assume in.txt consists of the following single line for Sample run1 and Sample run2:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Assume in.txt consists of the following two lines for Sample run3 and Sample run4:
A1 B2 C3 DEF
!@# CSCI151
After the program terminates, out.txt should contain these two lines:
B1 C2 D3 EFG
!@# DTDJ151
After the program terminates, out.txt should contain these two lines:
A1 B2 C3 DEF
!@# CSCI151
Assume in.txt consists of the following single line for Sample run5 and Sample run6:
TABLE
After the program terminates, out.txt should contain the following line:
UBCMF
After the program terminates, out.txt should contain the following line:
UBCMF