Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CS 241: Advanced Object-Oriented Programming using C++ Spring 2021 Homework 4 A school building has two floors with equal number of classrooms in each floor.

image text in transcribed
image text in transcribed
image text in transcribed
CS 241: Advanced Object-Oriented Programming using C++ Spring 2021 Homework 4 A school building has two floors with equal number of classrooms in each floor. On a Saturday, the principle went to the school to finish some work and he took his son with him. Being bored, the son decided to entertain himself by going around the building and checking each classroom door. If the door is closed, he opens it and if it is open he closes it To make it more exciting for himself, he decided to do this game in several rounds and change the status of certain doors esch round. Here is how he played the game For add rounds (rounds 1,3,5,cte.) he visits the first floor only and for even rounds, he visits the second floot only In each round, he doesn't visit all the doors on the floors be is visiting. He skips sono doors and Visits other doors depending on the round number. For example: o In Found 1 (odd round number), he visits the first floor and skips I door and visits door next to it and so until he finishes the floor. For example, he skips door 1 and visits door 2 then skips door 3 and visits door 4 and so on. In other words, in round 1, he visits every other door in floor o In round 2 (even round number), he visits the second floor and skips 2 doors and visits the third. For example, he skips doors 1 and 2 and visits door 3 then skips doors 4 and 5 and Visits door 6 and so on. This means, in round 2. he visits every second door in floor 2. o In Found 3 (odd round number), he visits the first floor and skips 3 doors and visits the fourth. For example, he skips doors 1, 2 and 3 and visits door 4 then skips doors 5, 6, and 7 and visits door and so on until he finishes the floor. In other words, he visits every third door in floor 1. Let's assume all the doors are closed when he starts Write a C++ program that simulates this game. The program should do the following 1- Ask the user to enter the number of classrooms per floor 2- Ask the user for the number of rounds in the game 3. Once this data is entered the program should simulate the game for the number of requested rounds then displays the total number of doors that will remain open at the end of the game and list them in cach look 4. The program should ask the user if they want to play again. If the answer a yek then it repeats again by asking for the parameters of the new game cromber of classrooms and round Here is an example of how the program should look like when it in the centers 30 classrooms per floor and round A RETO If the ser enters 10 inreon to the goes to the programasks for the umber of round a pointer to the floor classrooms array. You may also want to pass the number of classrooms in the floor o listOpenDoorso: This function will list all the doors that are open in a specific floor. The input to this function could a pointer to the floor classrooms array. You may also want to pass the number of classrooms in the floor . Do not use global variables. Each function should use it's local variables and the arguments passed to it from main . Since your programs will allocate dynamic memory during runtime you must make sure it doesn't have any memory leaks by releasing any dynamically allocated memory at the end of each game. . Part of your grade will be for the programming style used. Here are some guidelines: Each program should begin with a comment section giving the name of the file, the author's name, the date the file was last modified, and a description of its purpose. In addition, it is also considered good programming practice to include any assumptions you have made and any error-checking that has been provided. For example, 7 Filmmake change.PP Authoritate Data last moditied 2/10/2021 This program accepta a dollar amount pacified by the user and displays the minimum of $10.95 and $1 bilis alred to take up the amount +/ o Use meaningful and descriptive identifiers for variable names. This can make a program easier to understand o Add comments in your program to provide elarity for the reader. o Use consistent and reasonable indentation conventions throughout your program to improve program readability. Avoid using several spaces for an indent - instead use a tab. If there are several levels of indentation, cach level should be indented the same additional amount of space. When you are finished, submit your source code file in Blackboard by the due date. Your source code file is the file that has the C++ code the opp file Don't submit the Visual Studio solution file (the sin file). The only file you need to submit is the C source code file for your program. Ne picture or screen captures of your program is needed This is an individual assignment so your program should reflect your own algorithm implemented in CH. Carrying someone else's program and submitting it as if it was yours is plagiarism and will not be tolerated. Please refer to the Scholastic Dishonesty section of the COSET Student Handbook ++ a pointer to the floor classrooms array. You may also want to pass the number of classrooms in the floor o listOpenDoorso: This function will list all the doors that are open in a specific floor. The input to this function could a pointer to the floor classrooms array. You may also want to pass the number of classrooms in the floor . Do not use global variables. Each function should use it's local variables and the arguments passed to it from main. . Since your programs will allocate dynamic memory during runtime, you must make sure it doesn't have any memory leaks by releasing any dynamically allocated memory at the end of each game. . Part of your grade will be for the programming style used. Here are some guidelines Each program should begin with a comment section giving the name of the file, the author's name, the date the file was last modified, and a description of its purpose. In addition, it is also considered good programming practice to include any assumptions you have made and any crror-checking that has been provided. For example, 7. Filmmake change opp Authorit turk Data last modified 2/10/2021 This program accepta dollar amount apeiriad by the war and displays the minimum number of $20, 65 and $1 bis equired to make up the amount 1/ o Use meaningful and descriptive identifiers for variable names. This can make a program easier to understand Add comments in your program to provide elarity for the reader. o Use consistent and reasonable indentation conventions throughout your program to improve program readability. Avoid using several spaces for an indent - instead use a tab. If there are several levels of indentation, cach level should be indented the same additional amount of space. When you are finished, submit your source code file in Blackboard by the due date Your source code file is the file that has the C++ code the opp file Don't submit the Visual Studio solution file (then file). The only file you need to subunit is the source code file for your program. Ne picture or screen captures of your program is eeded This is an individual assignments your program should reflect your own algorithm implemented in C. Copying someone else's program and submitting it as if it was yours i plagiarism and will not be tolerated. Please refer to the Scholastic Dishonesty section of the COSET Student Handbook

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Upgrade Migration And Transformation Tips And Techniques

Authors: Edward Whalen ,Jim Czuprynski

1st Edition

0071846050, 978-0071846059

More Books

Students also viewed these Databases questions

Question

2 Novelty and unpredictability teach flexibility. Discuss.

Answered: 1 week ago

Question

b. Why were these values considered important?

Answered: 1 week ago