Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write valid Python code to implement the design shown in the following flow chart. The problem is provided to help make the flow chart clearer,

image text in transcribed
image text in transcribed

Write valid Python code to implement the design shown in the following flow chart. The problem is provided to help make the flow chart clearer, but you are not expected to use it in any way. In order to calculate the amount that the customer needs to pay, include the code import random as the first line of your file and then use amount = random.randint(0,20) + round( random.randint(0,100)/100, 2 ) to calculate the amount.

Completely test your code - there will be a major penalty if the code submitted cannot be run by your professor. In order to test your code, set amount to your test value after it is set by the random line. Create comments in your source code to state what values you used to test your program. A single test will not be sufficient to correctly test this program, so do not be concerned if you believe that you need to go through your program more than 1 time in order to completely test it.

Problem: A person is at a store and you have just processed their purchase. After you tell them the amount that they owe for their purchase they will hand you some money. If the amount given is the exact amount, then you should tell them that no change is owed. Otherwise, you should calculate the number of each denomination to give them back in their change. The denominations available are dollars (1.00), quarters (0.25), dimes (0.10), and nickels (0.05). Since Canada no longer has a penny the change should be rounded up to the nearest nickel. Once you have calculated the change you should tell the person how much change you have given them. In order to keep your customer happy, you should always give them the fewest coins possible, do not simply give them back all their change in nickels.

Note that some of the steps in the flow chart will require you to think about how to get Python to perform the calculation. There is no best way to do it that will earn more marks. Any valid, working Python code that correctly calculates the totals will be accepted. Do not, however, remove any of the conditional statements. There are two conditional blocks in the flow chart and there should be two in your solution since we are trying to practice writing them. You are expected to use meaningful variable names and comment any code you feel requires explanation.

Write vald Python code to implement the deven shown in the following how chart. The problem is provided to help make the flow chart clearer, but you are not expected to use itin any way. In order to calculate the amount that the customer needs to pay, include the code import rondom as the first line of your file and then use amount - rondomondint(0,20 + round random.rundint0, 100/100, 2) to calculate the amount Completely test your code there will be a major perally if the code submitted cannot be run by your professor. In order to test your code, at amount to your test value after it is set by the random line. Create comments in your source code to state what values you used to test your program. Asinde test will not be suficient to correctly test this program, so do not be concerned if you believe that you need to go through your program more than 1 time in order to completelytestit. For example 2 X file de format B DO Wndow Help Dort randon 1 Sample 12345678.rity that the work in Otact and this 1 bountandorandint co. 203 round ander.tandint 0 100 V100, 25 Tots the hostove 1973 Problem: A person is at a store and you have just processed their purchase. After you tell them the mount that they owe for their purchase they will hand you some money. If the amount iiven is the exact amount then you should tell them that no change is owed. Otherwise, you should cautate the number of each denomination to give them back change. The denominations available are dollars (10), quiers (0.25 dimes 10.10and richels 0.05). Since Canada no longer has a penny the charge should be rounded up to the nebrest nickel. Once you have calculated the change you should tell the person how much change you have gives them. In order to keep your customer hapow. You should them the fewest coins possible, do not simply give them back all their change in nickels Note that some of the steps in the flow chart will require you to think about how to get Python to perform the calculation. There is no best way to do it that will cam more at Any valid, working Python code that correctly calculates the totals will be accepted. Do not, however, remove any of the conditional statements. There are two conditional blocks in the w chart and there should be two in your solution since we are trying to practice writing them. You are expected to use meaningful variabile rames and comment any code you feel les explanation Question 2: Writing code from a design. (50%) Write valid Python code to plement the design shown in the following flow chart. The problem is provided to help make the flowchart cheww, but you are not expected to use in any way, in order to calculate the amount that the customer needs to pay, include the code importando as the first line of your file and the new random.ondine,201 round rando.de/0,1001100, 2) to calculate the amount. Completely test your code there will be a major penalty if the code submitted cannot be run by your professor. In der to test your code, et amount to your test after it is set by the random line. Create comments in your source code to state what vakes you used to test your program. A single test will not be sufficient to correctly test this program, so do not be concemned if you believe that you need to go through your program more than 1 time in order to completelytestit For example: # plity that this work is fort 1 trad. 301 + randomrandinto100/100.3 I will show - Problem A person is a store and you have just processed their purchase. After you tell them the amount that they owe for their purchase they will hand you some money, if the amount given is the exact amount, then you should tell them that no change is owed. Otherwise, you should calculate the number of each denomination to give them back in their change. The denominations available are dollars (1.001. quarters 0.25 dimes 10.101, and nickel 0.05. Since Canada no longer has a penny the change should be rounded up in the net nickel. Once you have calculated the change you should tell the person how much change you have given them. In order to keep your customer happy, you should always pive them the fewest coins possible, do not simply sive them back all their change in nichels Note that some of the steps in the flow chart will require you to think about how to get Python to perform the calculation. There is no best way to do it that will earn more mare. Any valid working Python code that correctly calculates the total will be accepted. Do not, however remove any at the conditional statements. There are two conditional lock in the low chart and there should be two in your solution since we are trying to practice writing them. You are expected to be meaningful variable names and comment any code you feel requires explanation

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_2

Step: 3

blur-text-image_3

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

Transactions On Large Scale Data And Knowledge Centered Systems Xxxviii Special Issue On Database And Expert Systems Applications Lncs 11250

Authors: Abdelkader Hameurlain ,Roland Wagner ,Sven Hartmann ,Hui Ma

1st Edition

3662583836, 978-3662583838

More Books

Students also viewed these Databases questions

Question

4. Identify cultural variations in communication style.

Answered: 1 week ago

Question

9. Understand the phenomenon of code switching and interlanguage.

Answered: 1 week ago

Question

8. Explain the difference between translation and interpretation.

Answered: 1 week ago