Concept explainers
Can you find the reason that the following pseudocode function does not return the value indicated in the comments?
// The calcDiscountPrice 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 calcDiscountPrice(Real price, Real percentage)
// Calculate 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
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Starting Out with Programming Logic and Design (4th Edition)
Additional Engineering Textbook Solutions
Software Engineering (10th Edition)
Database Concepts (8th Edition)
Starting out with Visual C# (4th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Starting Out With Visual Basic (7th Edition)
Starting Out with Java: Early Objects (6th Edition)
- python Write a split_check function that returns the amount that each diner must pay to cover the cost of the meal. The function has 4 parameters: bill: The amount of the bill. people: The number of diners to split the bill between. tax_percentage: The extra tax percentage to add to the bill. tip_percentage: The extra tip percentage to add to the bill. The tax or tip percentages are optional and may not be given when calling split_check. Use default parameter values of 0.15 (15%) for tip_percentage, and 0.09 (9%) for tax_percentage. Sample output with inputs: 25 2 Cost per diner: 15.5 Sample output with inputs: 100 2 0.075 0.21 Cost per diner: 64.25arrow_forwardDo not use global variables for this assignment Choose descriptive variable names in all programs. Currency format. There should be no space between the $ sign and the first digit. In python, Write a program that uses a custom function named as you wish and the main function. In main, prompt the user for a first name and an integer less than 10 and then execute the custom function with these two inputs as arguments. The custom function should output one line displaying the name as many times as specified by the integer, separating each repetition of the name with a space.arrow_forwardWrite a split_check function that returns the amount that each diner must pay to cover the cost of the meal. The function has 4 parameters: bill: The amount of the bill. people: The number of diners to split the bill between. tax_percentage: The extra tax percentage to add to the bill. tip_percentage: The extra tip percentage to add to the bill. The tax or tip percentages are optional and may not be given when calling split_check. Use default parameter values of 0.15 (15%) for tip_percentage, and 0.09 (9%) for tax_percentage. Sample output with inputs: 25 2 Cost per diner: 15.5 Sample output with inputs: 100 2 0.075 0.21 Cost per diner: 64.25 python # FIXME: Write the split_check function. HINT: Calculate the amount of tip and tax,# add to the bill total, then divide by the number of diners. ''' Your solution goes here ''' bill = float(input())people = int(input()) # Cost per diner at the default tax and tip percentagesprint('Cost per diner:', split_check(bill, people)) bill =…arrow_forward
- Using user-defined functions with Python. "Federal law requires that hourly employees be paid "time-and-a-half" for work in excess of 40 hours in a week. For example, if a person's hourly wage is \$12 and he or she works 60 hours in a week, the person's gross pay should be (40*12) + (1.5*12*(60-40)) = \$840 else it is (40*12) = \$480. Write a program that determine a person's weekly pay based on the calculation describe above. The main function should call three functions - one (multi-valued) for input, one to calculate the values, and one for output the person's gross pay." The attached screenshot is my code at the moment. I'm just stuck getting around this error. Thank you!arrow_forwardaccording to the instructions, the function will be written.Please don't refuse the question, it's clear.arrow_forwardThe prompt asks: Write a function that calculates the amount of money a person would earn over a period of years if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should ask the user for the number of years and call the function which will return the total money earned in dollars and cents, not pennies. Assume there are 365 days in a year. function totalEarned(years) { } var yearsWorked = parseInt(prompt('How many years will you work for pennies a day? ')); alert('Over a total of ' + yearsWorked + ', you will have earned $' + totalEarned(yearsWorked));arrow_forward
- The following program will prompt the user for a starting number and an // ending number. Assume that these are whole numbers (no decimal points), // assume the numbers are not negative and assume that the first number is // not larger than the second number. // // write a funcTion that returns the sum of the numbers from the starting // number to the ending number. For example, if the starting number is 13 // and the ending number is 18 then the function will return the value of // 13 + 14 + 15 + 16 + 17 + 18. If the starting number is equal to the ending // number then simply return that number. // ////////////////////////////////////////////////////////////////////////// function sumOfNumbers(startingNumber, endingNumber) { } var startingNumber = parseInt(prompt('What is the starting number? ')); var endingNumber = parseInt(prompt('What is the ending number? ')); var sumOfNumbersPassed = sumOfNumbers(startingNumber, endingNumber); alert('The sum of the numbers from ' +…arrow_forwardYou must have 2 functions: one computes the average and the other finds the letter grade. The average function should return back a Real value and the letter grade function should return back a string. All input and output must occur in main(). Only find and display the letter grade for the average, not each test score. Just the algorithm in pseudo codearrow_forwardYour program will prompt the user for the following information: current population number of yearly births from the previous year number of yearly deaths from the previous year number of years into the future for your predictive value of the future population. You will then compute the following: birth rate death rate growth rate the predicted future population Assignment Notes: To allow the user to input the numeric data (such as current population) it is necessary to use the input function. The input function takes a string in parenthesis that prompts the user what to enter. The computer then waits until the user types a response, terminated by the user typing the Enter key. A string, as a sequence of characters, is returned to the variable on the lefthand side of the assignment statement. For example: currPopulation = input(“Enter the current US population”) The data in currPopulation is a string (because that is what the input statement does) but we need it to be a number…arrow_forward
- In physics, an object that is in motion is said to have kinetic energy. The following formula can be used to determine a moving object’s kinetic energy:KE=12mv2The variables in the formula are as follows: KE is the kinetic energy, m is the object’s mass in kilograms, and v is the object’s velocity in meters per second. Write a function named kinetic_energy that accepts an object’s mass (in kilograms) and velocity (in meters per second) as arguments. The function should return the amount of kinetic energy that the object has. Write a program that asks the user to enter values for mass andvelocity, then calls the kinetic_energy function to get the object’s kinetic energy.arrow_forwardPython XYZ store plans to give a festival discount to its customers. The store management has decided to give discount on the following criteria: Shopping Amount Discount Offered >=500 and <1000 5% >=1000 and <2000 8% >=2000 10% An additional discount of 5% is given to customers who are the members of the store. Create a program using user defined function that accepts the shopping amount as a parameter and calculates discount and net amount payable on the basis of the following conditions:Net Payable Amount = Total Shopping Amount – Discount.arrow_forwardYou must have 2 functions: one computes the average and the other finds the letter grade. The average function should return back a Real value and the letter grade function should return back a string. All input and output must occur in main(). Only find and display the letter grade for the average, not each test score. Just a basic algorithm in pseudo codearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education