Question 1
This question covers materials in Seminar 1 and 2. Use and express selection structure for this question. Functions, repetition, or collections are not required for this question.
Company O uses the following table to help customers determine their T-Shirt size
(a) Write a program that helps customers find their T-Shirt size. The program reads in the chest measurement in centimetres and displays the T-Shirt size.
Assume user will enter valid input. Sample program executions are as follows:
As online ordering has increased in folds during the pandemic, the number of returns and exchanges also increased, due to wrong fittings. In order to provide better services and better fittings, company O has enhanced Table 1-1 to include Height and Waist measurements.
(b) Using Table 1-2, write a program to recommend the T-Shirt size, based on customers’ height, chest, and waist measurements. Your program must display the appropriate “fitting” based on the following fitting rules:
o best fit: if all three measurements indicate same size.
o regular fit: if two measurements indicate same larger size than the third. See Sample execution 2 below.
o relaxed fit: if one measurement indicates larger size than the other two. See sample execution 3 below.
For each part, submit separate python codes and paste screenshots of at least THREE (3) program executions, with different input
Question 2
This question covers materials up to Seminar 3. Make use of functions, selection, and repetition structures. NO data structures like sets, lists or dictionary should be used for this question.
Keep the program modular by defining other functions if necessary.
Scissors-Paper-Stone (also known by other orderings of the three items, with “stone” sometimes being called “rock”) is a hand game originating from China, usually played between two people, in which each player simultaneously forms one of three shapes with an outstretched hand. These shapes are “stone” (a closed fist), “paper” (a flat hand), and “scissors” (a fist with the index finger and middle finger extended, forming a V).
The game has three outcomes: a draw, a win or a loss. A player who decides to play stone will beat another player who has chosen scissors (“stone crushes scissors” or “breaks scissors”) but will lose to one who has played paper (“paper covers stone”); a play of paper will lose to a play of scissors (“scissors cuts paper”). If both players choose the same shape, the game is tied (draw).
(a) Implement TWO (2) functions:
getShape() that prompts, validates and returns the player’s shape selection of “Scissors”, “Paper”, “Stone” in uppercase.
getRandomShape() that returns a random pick from “Scissors”, “Paper”, “Stone” in uppercase
(b) Write a program to play the game of Scissors-Paper-Stone, using structured programming. Your program will allow a player to play three rounds of Scissors-PaperStone against the computer.
The scope of the program is as follows:
At start of the game, allow player to enter his/her name.
For each round, computer will randomly pick a shape, and ask player to select
a shape. Make use of the functions you created in question 2(a).
Your program will compare the player’s shape against the computer’s pick,
determine the outcome of this round and award one point to the winner. Do not award point if it is a tie.
Display current score before start of next round.
At the end of three rounds, display the winner of the game (if any).
If the result after 3 rounds is a tie, repeat the game (3-rounds) again, until a
winner can be determined.
(c) Write a new version of the Scissors-Paper-Stone game that will need a player to win THREE (3) consecutive rounds to be winner. The scope of the program is as follows:
At start of the game, allows player to enter his/her name.
For each round, computer will randomly pick a shape, and ask player to select a shape. Make use of the functions you created in question 2(a).
Your program will compare the player’s shape against the computer’s pick,
determine the outcome of this round:
o Award one point to the winner. Reset the loser’s score to 0.
o Do not award point if it is a tie. Reset both player and computer score to 0
Repeat the round until a player reaches THREE points (i.e., wins 3 consecutive
rounds)
Question 3
This question covers materials up to seminar 4. The data structure to use is List. You can use more than ONE list. No nested list or dictionary collection is required for this question.
This question is similar to Q2, but with Scissors-Paper-Stone played like poker game.
(a) Implement a function getHandOfShapes(size, auto) that has an integer parameter (size) representing the number of shapes and a boolean parameter (auto) indicating if the shapes are randomly selected. Size must be at least 3. If auto is False, the function will prompt the player to indicate the shapes (Scissors-Paper-Stone) they would like to have, in sequential order and returns the selected shapes as a list.
Duplicated shapes are fine. Examples for a hand of shapes (size 6):
SCISSORS, PAPER, STONE, PAPER, STONE, SCISSORS
PAPER, PAPER, PAPER, PAPER, PAPER, PAPER
(b) Employ structured programming to develop a new game with rules as follows:
At start of the game, prompt for the size of hand.
Size must be at least 3. If not, ask user to re-enter the size.
After capturing the player’s name, proceed to create the player’s hand of shapes. Make use of the getHandOfShapes() function in Q3(a).
Your program will also setup computer’s hand of shapes, according to the size entered.
Next is to compare the computer and players’ hand of shapes, one-by-one, and award one point to the winner. Do not award point if it is a tie.
After comparing the hand of shapes, display the winner of the game (if any).
If the result is a tie, repeat the game with new hand of shapes, until a winner can be determined.
(c) Write a new game, by enhancing Q3(b) with the following new rules:
In a hand of n shapes, there should not be more than n/2 of same shapes. This applies to both player and computer.
After comparing the hand of shapes and the result is a tie, the game will into a playoff.
In a playoff, computer will randomly pick a shape, and ask player to select a
shape. Make use of the functions you created in Q2(a).
Your program will compare the player’s shape against the computer’s pick and display the winner. If it is still a tie, this playoff format continues until there is a winner
Question 4
The question covers concepts in all the seminars. Employ structure programming and use of functions to make the program modular.
FR (Fry Rice) is a popular art theatre company and is looking for a simple application to help them dynamically setup seating arrangements for their stage performances or productions.
This is important to FR due to the different measures applied during the pandemic. In addition, FR is also looking for the application to allow FR admin to perform booking and cancellation of seats.
Apply data structures to store and process information. The scope and assumptions for this
question are as follow:
Each performance has its own seating plan.
To setup a performance, FR uses a file to store the seating plan, with filename consisting of production title and performance datetime. For example,
o Production title “Bad Citizen”, performing on 18-Oct-2022 19:30 will have the seating plan setup in file Bad Citizen-202210181930.txt
o Production title “Monkey Goes East”, performing on 8-Sep-2022 14:30 will have the seating plan setup in file Monkey Goes East-202209081430.txt
o See Appendix A for more files for different productions’ seating plans.
Blocked seats are marked with #, empty or available seats are marked with O, while those booked are marked with X.
(a) A theatre has rows of seats. The rows are labelled A, B, C, etc and seat numbers 1, 2, 3 etc. A seating plan for production title “Monkey Goes East”, performing on 8-Sep-2022 2:30pm, could look as follows:
The above seating plan is stored in a file, Monkey Goes East-202209081430.txt as follows:
A,OXXX#XXXX#XXOO
B,OOXX#XXXX#XXOO
C,OXXX#XXXO#OXXO
D,OOXX#XXXX#XXOO
E,OOOX#OXXO#XXOO
F,##XX#OXXX#XO##
(i) Write a function readSeatingPlan(filename) where the parameter is a string representing the filename that the seating plan is stored. This function reads the file and store the seating plan in a dictionary. The dictionary structure after reading the file should be as follows:
seatingPlan = {
‘A’:[‘O’,’X’,’X’,’X’,’#’,’X’,’X’,’X’,’X’,’#’,’X’,’X’,’O’,’O’],
‘B’:[‘O’,’O’,’X’,’X’,’#’,’X’,’X’,’X’,’X’,’#’,’X’,’X’,’O’,’O’],
. . .
. . .
‘F’:[‘#’,’#’,’X’,’X’,’#’,’O’,’X’,’X’,’X’,’#’,’X’,’O’,’#’,’#’], }
The key is the row labels, and the value is a list consisting of the seat statuses. For example, the row A consists of a list, where seat 1 is empty, 2 is booked, 3 is booked, 4 is booked and 5 is blocked etc.
(ii) Write a function show Seating Plan(seating Plan) that will display the seating plan as shown in Table 4-1. The parameter is a dictionary representation of the seating plan.
(b) Write an application that manages the seat booking process for FR. The program has a main menu, where current production titles are listed in alphabetical order, followed by the performance datetime in chronological order, as follows:
Main Menu – FR Productions
==========================
1. Bad Citizen @ 2022-09-08 19:30
2. Bad Citizen @ 2022-09-09 19:30
3. Monkey Goes East @ 2022-09-08 14:30
4. Monkey Goes East @ 2022-09-09 14:30
X. Exit
Enter selection: _
Assuming user selected 1 (Bad Citizen @ 2022-09-08 19:30), the production title, performance datetime, seating plan and the sub-menu will be presented. Production: Bad Citizen Performance datetime: 2022-09-08 19:30
Seating plan:
A O O O O O # O X X X X # X O O O O
B O O O O X # X X X O O # X O O O O
C O O O O X # O X X O O # O O O O O
D O O O O X # O O X X X # X O O O O
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17
Sub-Menu
========
1. Book Seats
2. Cancel Bookings
In this menu, there are options/functions that FR admin can perform: booking of seats and cancellation of bookings. The following sections will detail the setup and functionalities required for this application.
(i) Before presenting the main menu, your application needs to do the following:
Read the file “FR_Productions.txt” that contains the filenames of the
seating plan for all current productions:
Bad Citizen-202209081930.txt
Bad Citizen-202209091930.txt
Monkey Goes East-202209081430.txt
Monkey Goes East-202209091430.txt
Decipher the production title and performance datetime from the filenames, such that the main menu (Table 4-2) can list all production titles in same order in the file “FR_Productions.txt.
When the user selects a production, the application will proceed to load the corresponding seating plan into a dictionary, using Q4(a)(i).
If the seating plan is successfully loaded, proceed to display the production title, performance datetime, seating plan and the sub-menu (Table 4-3).
(ii) The “Book Seats” option in the sub-menu only apply to the production that is chosen at main menu.
To book seats, user just enter the row labels and seat numbers in these
formats:
o B1 – indicating a single seat at row B, seat number 1
o B3,B4,C3,C4 – indicating 4 seats, separated by commas Assume that user will enter valid input.
This option will then validate that all seats selected must be available, i.e.,
not occupied or blocked before allowing this booking.
The selected seats will be updated to X and confirmation message should be displayed.
Below are examples of successful and unsuccessful booking:
Regardless of the booking status, the application will re-display Table 4-3, pending user to select the next action/option.
Present screenshots of successful and unsuccessful bookings.
(iii) The “Cancel Bookings” option in the sub-menu apply to the production that is chosen at main menu.
To cancel bookings, user just enter the row labels and seat numbers in these
formats:
o B1 – indicating a single seat at row B, seat number 1
o B3,B4,C3,C4 – indicating 4 seats, separated by commas Assume user will enter valid input.
This option will then validate that all seats selected must be occupied, i.e., not empty or blocked, before allowing this cancellation.
The selected seats will be updated to O and confirmation message should be displayed.
Below are examples of successful and unsuccessful cancellation:
Regardless of the cancellation status, the application will re-display Table 4-3, pending user to select the next action/option.
Present screenshots of successful and unsuccessful cancellations.
(iv) When user exits from sub-menu, i.e., selected option “Back to Main Menu”, the application must write the latest seating plan for this production back into the file.
Appendix A
The following 4 files are samples of seating plan for FR productions.
File 1: Monkey Goes East-202209081430.txt
A,OXXX#XXXX#XXOO
B,OOXX#XXXX#XXOO
C,OXXX#XXXO#OXXO
D,OOXX#XXXX#XXOO
E,OOOX#OXXO#XXOO
F,##XX#OXXX#XO##
File 2: Monkey Goes East-202209091430.txt
A,OOOX#XXXX#XXOO
B,OOXX#XXXO#XXOO
C,OOXX#OXXO#OOOO
D,OOXX#XXXX#XXOO
E,OOOO#OOOO#OOOO
F,##OO#OOOO#OO##
File 3: Bad Citizen-202209081930.txt
A,OOOOO#OXXXX#XOOOO
B,OOOOX#XXXOO#XOOOO
C,OOOOX#OXXOO#OOOOO
D,OOOOX#OOXXX#XOOOO
File 4: Bad Citizen-202209091930.txt
A,OOOOO#OXXXX#XOOOO
B,OOOOO#XXXOO#XOOOO
C,OOOOO#OXXOO#OOOOO
D,OOOOO#OOXXX#XOOOO
Buy Custom Answer of This Assessment & Raise Your Grades
The post ICT133:Write a program that helps customers find their T-Shirt size The program reads in the chest measurement in centimetres and displays the T-Shirt size: Structured Programming TMA Assignment, SUSS appeared first on Singapore Assignment Help.