Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Alain just opened a gym in 2017 and he already has 100 members. According to its forecasts, the number of members should increase by

Python

Alain just opened a gym in 2017 and he already has 100 members. According to its forecasts, the number of members should increase by 8% per year. Write a program to help Alain in his forecasts of number of members, following the specifications described below.

The number of members each year will be rounded to the nearest integer thanks to the round function (...). For example, round(6.8) is 7.

When Alain launches the application, the following menu should be displayed:

Menu, please choose:

1. Forecasts adhering to year N (summary)

2. Forecasts adhering to year N (details)

3. Cumulative memberships in year N

4. Year in which M members will be obtained

Q. Quit

If Alain types 1, the program displays him Choose a year: then the number of members that there will be in the chosen year, for example if Alain taps 2018, the program must display In 2018 there will be 108 adherents. Then, the program should re-display the menu.

If Alain types 2, the program displays him Choose a year: then the details of the number of members expected from the year 2017 to the chosen year. For example if Alain types 2019, the program should display:

In 2017 there are 100 adherents.

In 2018 there will be 108 adherents.

In 2019 there will be 117 adherents.

Then, the program should re-display the menu.

If the chosen year is less than or equal to 2017, only the line In 2017 there are 100 adherents. should be displayed.

If Alain types 3, the program displays him Choose a year: then the number of memberships accumulated between the year 2017 and the year chosen (because each member must renew his membership each year). For example if Alain types 2019, the program must display From 2017 to 2019 there will be 325 cumulative memberships. (this is the sum of the numbers displayed in choice 2 of the menu). Then, the program should re-display the menu.

If Alain types 4, the program displays him Enter the desired number of adherents: then the year from which this number of members will be reached. For example, if Alain types 115, the program should display We will reach 115 members in 2019. Then, the program should re-display the menu.

If Alain types Q, the program shows him Goodbye. and stops.

If Alain types something other than 1, 2, 3, 4 or Q, the program must answer him Invalid Choice, start again: (without re-displaying the menu) and start displaying this sentence again until his choice becomes valid.

Example 1:

Menu, please choose:

1. Forecasts adhering to year N (summary)

2. Forecasts adhering to year N (details)

3. Cumulative memberships in year N

4. Year in which M members will be obtained

Q. Quit

4

Enter the number of adherents you want: 203

We will reach 203 members in 2027.

Menu, please choose:

1. Forecasts adhering to year N (summary)

2. Forecasts adhering to year N (details)

3. Cumulative memberships in year N

4. Year in which M members will be obtained

Q. Quit

Q

Good bye.

Exemple 2:

Menu, veuillez choisir :

1. Forecasts adhering to year N (summary)

2. Forecasts adhering to year N (details)

3. Cumulative memberships in year N

4. Year in which M members will be obtained

Q. Quit

1

Choose a year: 2020

In 2020 there will be 126 adherents.

Menu, please choose:

1. Forecasts adhering to year N (summary)

2. Forecasts adhering to year N (details)

3. Cumulative memberships in year N

4. Year in which M members will be obtained

Q. Quit

5

Invalid choice, repeat: -1

Invalid choice, repeat: 1

Choose a year: 2023

In 2023 there will be 159 adherents.

Menu, please choose:

1. Forecasts adhering to year N (summary)

2. Forecasts adhering to year N (details)

3. Cumulative memberships in year N

4. Year in which M members will be obtained

Q. Quit

3

Choose a year: 2020

From 2017 to 2020 there will be 451 cumulative memberships.

Menu, please choose:

1. Forecasts adhering to year N (summary)

2. Forecasts adhering to year N (details)

3. Cumulative memberships in year N

4. Year in which M members will be obtained

Q. Quit

Q

Good bye.

Example 3:

Menu, please choose:

1. Forecasts adhering to year N (summary)

2. Forecasts adhering to year N (details)

3. Cumulative memberships in year N

4. Year in which M members will be obtained

Q. Quit

2

Choose a year: 2023

In 2017 there are 100 adherents.

In 2018 there will be 108 adherents.

In 2019 there will be 117 adherents.

In 2020 there will be 126 adherents.

In 2021 there will be 136 adherents.

In 2022 there will be 147 adherents.

In 2023 there will be 159 adherents.

Menu, please choose:

1. Forecasts adhering to year N (summary)

2. Forecasts adhering to year N (details)

3. Cumulative memberships in year N

4. Year in which M members will be obtained

Q. Quitter

Q

Good bye.

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

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions

Question

Explain the need for and importance of co-ordination?

Answered: 1 week ago

Question

Explain the contribution of Peter F. Drucker to Management .

Answered: 1 week ago

Question

What is meant by organisational theory ?

Answered: 1 week ago

Question

What is meant by decentralisation of authority ?

Answered: 1 week ago