Question

Can you find the reason that the following pseudocode function does not return the value indicated...

Can you find the reason that the following pseudocode function does not return the value indicated in the comments?

// The setDiscountPrice function accepts an item's price and the discount percentage

// as arguments. It uses those values to calculate and return the discounted price.

Function Real setDiscountPrice(Real price, Real percentage)

     // Set the discount.

     Declare Real discount = price * percentage

     // Subtract the discount from the price.

     Declare Real discountPrice = price - discount

     // Return the discount price.

     Return discount

End Function

Homework Answers

Answer #1

Solution

Answer

The pseudocode should

return the discountPrice not return discount

Explanation

if you observe the pseudocode
in the commment it clearly describes return the discount price
but in the code it is mentioned
return discount
should be changed
return discountPrice

---

all the best

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1. Write a function called compute_discount which takes a float as the cost and a Boolean...
1. Write a function called compute_discount which takes a float as the cost and a Boolean value to indicate membership. If the customer is a member, give him/her a 10% discount. If the customer is not a member, she/he will not receive a discount. Give all customers a 5% discount, since it is Cyber Tuesday. Return the discounted cost. Do not prompt the user for input or print within the compute_discount function. Call the function from within main() and pass...
Write a function to find the indices of a time series in which the absolute value...
Write a function to find the indices of a time series in which the absolute value of the derivative is above a particular threshold. This is somewhat based on work we’ve done in this chapter. The function: (a) should be named where_deriv_large. (b) should take two arguments: times, data (in that order). (c) (509 only) should have a third argument in which the value of the threshold can be passed. (d) should return a tuple. The first element is the...
What is a “basis point”? ANSWER:            Can you easily find asset classes that possess positive...
What is a “basis point”? ANSWER:            Can you easily find asset classes that possess positive returns, above that of inflation, which also possess negative correlation? (Yes or No.) ANSWER:            Explain the concept of “multi-asset class investing” in your own words. ANSWER:            The author states that both “U.S. stocks and U.S. bonds have real positive returns over time.” What is “real return”? What is “nominal return”? ANSWER:            The author states: “There is no known way to design a portfolio that...
1 A renewable energy electricity supply technology has the following characteristics: Capital cost ($) Annual operating...
1 A renewable energy electricity supply technology has the following characteristics: Capital cost ($) Annual operating cost ($) Lifetime (years) Salvage value ($) Annual electricity supplied (MWh) 300 000 27 200 25 40 000 400 1.1 If the owner can sell the electricity at 25 c/kWh, what is the simple payback period for the technology? 1.2 Would the owner invest in this technology if (s)he set a strict maximum four-year payback period? 1.3 What would the selling price for the...
art Three Present Value Index When funds for capital investments are limited, projects can be ranked...
art Three Present Value Index When funds for capital investments are limited, projects can be ranked using a present value index. A project with a negative net present value will have a present value index below 1.0. Also, it is important to note that a project with the largest net present value may, in fact, return a lower present value per dollar invested. Let's look at an example of how to determine the present value index. The company has a...
1. PRSET( 1D+E) For each of the following countries, find and report the major stock market...
1. PRSET( 1D+E) For each of the following countries, find and report the major stock market index values for March 2017 and March 2018 (in this exact order, please do not change): Switzerland (^SSMI), Mexico (^MXX), India (^BSESN), Japan (^N225), France (^FCHI). You can find these data at: http://finance.yahoo.com by entering the symbols above in parentheses for each country in the search box at the top of the page. Click on “Historical Data” and then select “Monthly” for “Frequency” and...
Use R to do each of the following. Use R code instructions that are as general...
Use R to do each of the following. Use R code instructions that are as general as possible, and also as efficient as possible. Use the Quick-R website for help on finding commands. 1. Enter the following values into a data vector named Dat: 45.4 44.2 36.8 35.1 39.0 60.0 47.4 41.1 45.8 35.6 2. Calculate the difference between the 2nd and 7th entries of this vector using only reference indices. 3. Calculate the median of Dat. 4. Sort the...
Using python 3.5 or later, write the following program. A kidnapper kidnaps Baron Barton and writes...
Using python 3.5 or later, write the following program. A kidnapper kidnaps Baron Barton and writes a ransom note. It is not wrriten by hand to avoid having his hand writing being recognized, so the kid napper uses a magazine to create a ransom note. We need to find out, given the ransom note string and magazine string, is it possible to given ransom note. The kidnapper can use individual characters of words. Here is how your program should work...
1.) Sam Strother and Shawna Tibbs are vice presidents of Mutual of Seattle Insurance Company and...
1.) Sam Strother and Shawna Tibbs are vice presidents of Mutual of Seattle Insurance Company and co-directors of the company’s pension fund management division. An important new client, the North-Western Municipal Alliance, has requested that Mutual of Seattle present an investment seminar to the mayors of the represented cities, and Strother and Tibbs, who will make the actual presentation, have asked you to help them by answering the following questions. a. What are the key features of a bond? b....
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT