Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A computer game to ascend a building with a specified number of floors. You have three different facilities for each floor to reach the top:

A computer game to ascend a building with a specified number of floors. You have three different facilities for each floor to reach the top: the elevator (1), the escalator (2), and walking up the stairs (3).
Each facility has its own scoring rule. Assume the initial score is zero.
Elevator (1): Score increments to the next even number.
Escalator (2): Score increments to the next odd number.
Walk (3): Score increments to the next prime number.
Write an algorithm and python code to display the score to ascend a building. [Difficult]
Example: If number of floors 4 and person chosen 3 for first floor, 2 for second floor, 3 for third floor and 2 for fourth floor. The score is 2(first prime number)+1(first odd number)+3(next prime number)+3(next odd number)=9.
Inputs:
Number of floors (n)
Enter facility number (1 or 2 or 3 n-times)
Output:
Score
Test cases:
Test 1: 1
--- Input ---
5
1
2
3
1
2
--- Expected output (numbers)---
12
Test 2: 2
--- Input ---
10
1
2
3
3
2
1
1
2
3
3
--- Expected output (numbers)---
38
Test 3: 3
--- Input ---
7
3
3
3
3
3
3
3
--- Expected output (numbers)---
58
Test 4: 4
--- Input ---
6
3
2
3
2
3
2
--- Expected output (numbers)---
19

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

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago