Exercise 2 Price Calculator Your boss at Amalgamated Sales Inc. is wary of complex topics such...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Exercise 2 "Price Calculator" Your boss at Amalgamated Sales Inc. is wary of complex topics such as division. He asks you to create a program that will calculate the average price of an item given the cost for a number of them. Write a program named average.py that inputs (from the keyboard) the name of an item, the number of items purchased, and the total price paid per item (in that order). The program should then calculate the average price per item and store it in a variable. Then it should output the average price. Your output and input should look like this, for example: >>> %Run average.py Enter the item name: banana Enter the number purchased: 100 Enter the total price: 153 The average price of a(n) banana is 1.53 dollars The prompts and output should match this example exactly, substituting the appropriate values. Note that you must calculate the average price yourself and format it to two decimal places. The name should be a string, the number purchased should be an integer, and the total price should be an integer number of dollars. Exercise 2 "Price Calculator" Your boss at Amalgamated Sales Inc. is wary of complex topics such as division. He asks you to create a program that will calculate the average price of an item given the cost for a number of them. Write a program named average.py that inputs (from the keyboard) the name of an item, the number of items purchased, and the total price paid per item (in that order). The program should then calculate the average price per item and store it in a variable. Then it should output the average price. Your output and input should look like this, for example: >>> %Run average.py Enter the item name: banana Enter the number purchased: 100 Enter the total price: 153 The average price of a(n) banana is 1.53 dollars The prompts and output should match this example exactly, substituting the appropriate values. Note that you must calculate the average price yourself and format it to two decimal places. The name should be a string, the number purchased should be an integer, and the total price should be an integer number of dollars.
Expert Answer:
Answer rating: 100% (QA)
Heres a Python program named averagepy that implements the described ... View the full answer
Related Book For
Numerical Methods For Engineers
ISBN: 9780071244299
5th Edition
Authors: Steven C. Chapra, Raymond P. Canale
Posted Date:
Students also viewed these programming questions
-
In this question you will be asked to reflect on a project you have been involved in or observed, in which a design evolved, or could have evolved, through applying a theory of user behaviour. You...
-
In a Hopfield neural network configured as an associative memory, with all of its weights trained and fixed, what three possible behaviours may occur over time in configuration space as the net...
-
Jaclyn Hargrove is the owner of six Pickwick Restaurants. For the past 10 years, she has always relied on her accountant to analyze her financial statements. Jaclyn feels that if she were able to...
-
Magi-Clean Vacuum produces a single product, a vacuum cleaner, in a continuous production process. At the beginning of production, 85 percent of materials are added; the other 15 percent are added...
-
Five independent samples, each of size n, are to be drawn from a normal distribution where is known. For each sample, the interval (y 0.96n, y + 1.06n) will be constructed. What is the probability...
-
A major department store chain is having a sale on refrigerators. The number of refrigerators sold during this sale at a sample of ten stores was: $\begin{array}{llllllllll}80 & 110 & 0 & 40 & 70 &...
-
On January 1, 2014, Jade Company issued $2,000,000 face value, 7%, 10-year bonds at $2,147,202. This price resulted in a 6% effective-interest rate on the bonds. Jade uses the effective-interest...
-
What role does strategic communication play in crisis mitigation and reputation management, leveraging narrative frameworks to maintain stakeholder trust and confidence?
-
A: Sales, Production, & Direct Materials Budget Oak Creek Company is preparing its master budget for 2020. Relevant data pertaining to its sales, production, and direct materials budgets are as...
-
What are the components of a time-series model? When does an annual time series require smoothing? Explain the moving average method of smoothing time series data and forecasting.
-
What is the importance of business forecasting?
-
An Italian food company operates several restaurants across Europe. The file Restaurant contains a sample of 85 restaurants located across seven European countries. Variables included are the seating...
-
The trial balance extracted from the books of Tailor Times Ltd at 31 December 2016 was as follows: You are given the following additional information: (1) The authorized and issued share capital is...
-
n = 200, p = 0.4. Assume the size of the population is 10,000. Describe the sampling distribution of p.
-
Briefly explain your answers Fig.1 1. Assuming the monopoly pictured above is a profit maximizing monopoly, what price will the monopoly charge for its output? 2. The profit maximizing monopoly will...
-
Test whether the 5-year survival rate for breast cancer is significantly different between African American and Caucasian women who are younger than 50 years of age and have localized disease....
-
Consider the linear programming problem: Maximize (x, y) = 6x + 8y Subject to 5x + 2y 40 6x + 6y 60 2x + 4y 32 x 0 y 0 Obtain the solution: (a) Graphically. (b) Using the simplex method. (c)...
-
The bubble sort is an inefficient, but easy-to-program, sorting technique. The idea behind the sort is to move down through an array comparing adjacent pairs and swapping the values if they are out...
-
Repeat Example 29.1, but use 49 interior nodes (that is, x = y = 5 cm).
-
a. Show that the mean-squared forecast error \(E\left[\left(\hat{y}_{T+1}-y_{T+1} ight)^{2} \mid I_{T} ight]\) for a forecast \(\hat{y}_{T+1}\), that depends only on past information \(I_{T}\), can...
-
Consider the AR(1) model \(y_{t}=\delta+\theta y_{t-1}+e_{t}\) where \(|\theta|)=0\) and \(\operatorname{var}\left(e_{t} \mid I_{t-1} ight)=\sigma^{2}\). Let \(\bar{y}_{-1}=\sum_{t=2}^{T} y_{t}...
-
Consider a stationary model that combines the \(\operatorname{AR}(2)\) model \(y_{t}=\delta+\theta_{1} y_{t-1}+\theta_{2} y_{t-2}+e_{t}\) with an \(\mathrm{AR}(1)\) error model \(e_{t}=ho...
Study smarter with the SolutionInn App