Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Step 1: Write a function that takes as input the following parameters:
1. The gender of the child
2. The height of the mother in inches
3. The height of the father in inches
The function should return the estimated height of the child in inches as an integer.
Your function should use the following formulas to give the correct answer based on the gender of the
child:
- Height of male child: ((Mother’s height * 13/12) + Father’s height) / 2
- Height of female child: ((Father’s height * 12/13) + Mother’s height) / 2
Convert the height of the child to an integer. The above formulas will give you a floating point number
so be sure to convert to a whole number.
Step 2: Write a function that takes as input the following:
1. The height of the child in inches as an integer
The function should output the height of the child in feet and inches (i.e. 64 inches is 5 feet and 4
inches).
Step 3: Create a main function/program that does the following:
1. The main function should ask the user for the gender of their child.
2. The main function should ask the user for the height of the mother in inches.
3. The main function should ask the user for the height of the father in inches.
4. The main function should then use the function from Step 1 to get the height of the child in
inches.
5. The main function should then use the function from Step 2 to produce the height of the child in
feet and inches.
6. The main function should have a loop so that the user can calculate the heights of as many
children as they wish.
Step 4: Submit your flowchart(s) for each step of the problem. Also, submit your program with good
comments and variable names.
1. The gender of the child
2. The height of the mother in inches
3. The height of the father in inches
The function should return the estimated height of the child in inches as an integer.
Your function should use the following formulas to give the correct answer based on the gender of the
child:
- Height of male child: ((Mother’s height * 13/12) + Father’s height) / 2
- Height of female child: ((Father’s height * 12/13) + Mother’s height) / 2
Convert the height of the child to an integer. The above formulas will give you a floating point number
so be sure to convert to a whole number.
Step 2: Write a function that takes as input the following:
1. The height of the child in inches as an integer
The function should output the height of the child in feet and inches (i.e. 64 inches is 5 feet and 4
inches).
Step 3: Create a main function/program that does the following:
1. The main function should ask the user for the gender of their child.
2. The main function should ask the user for the height of the mother in inches.
3. The main function should ask the user for the height of the father in inches.
4. The main function should then use the function from Step 1 to get the height of the child in
inches.
5. The main function should then use the function from Step 2 to produce the height of the child in
feet and inches.
6. The main function should have a loop so that the user can calculate the heights of as many
children as they wish.
Step 4: Submit your flowchart(s) for each step of the problem. Also, submit your program with good
comments and variable names.
Take Problem #1 from the Midterm Exam Study Guide. Turn the program into one that uses functions.
Step 1: Create a function that calculates the subtotal amount for the customer. The function should
have the following parameters:
1. Number of rooms
2. Number of nights
The function will calculate the subtotal amount as:
Subtotal Amount = (number of rooms * number of nights * 112.50)
The function should return the subtotal amount.
Step 2: Create a function to calculate the discount price. The function should have the following
parameters:
1. The subtotal amount
This function will ask the user if they are a new customer. If they are not, the function will return a
discount price of 0. Otherwise, the function will return the discount price:
Discount Price = Subtotal Price * .20
Step 3: Create a function to calculate the total price. The function should take in the following
parameters:
1. The subtotal amount
2. The discount price
The function will calculate the total price as the subtotal minus the discounted price. The function will
return the total price.
Step 4: Create a function to print the user’s receipt. The function should take in the following
parameters:
1. The customer’s name
2.Subtotal amount
3. Discount price
4. Total price
The function will print/display a receipt on-screen that show’s the customer’s name, subtotal, discount,
and total price. All monetary values should be printed with a “$” in the front of the output and
formatted to 2 decimal places. Do not use round.
Step 5: Create a main function that does the following:
1. Ask the user for their name
2. Ask the user for the number of rooms being purchased
3. Ask the user how many nights they plan to stay
4. Finds the subtotal by using the function from Step 1
5. Finds the discount price by using the function from Step 2
6. Finds the total price by using the function from Step 3
7. Prints the user’s receipt using the function from Step 4
Step 6: Submit your program to Canvas.
4. Total price
The function will print/display a receipt on-screen that show’s the customer’s name, subtotal, discount,
and total price. All monetary values should be printed with a “$” in the front of the output and
formatted to 2 decimal places. Do not use round.
Step 5: Create a main function that does the following:
1. Ask the user for their name
2. Ask the user for the number of rooms being purchased
3. Ask the user how many nights they plan to stay
4. Finds the subtotal by using the function from Step 1
5. Finds the discount price by using the function from Step 2
6. Finds the total price by using the function from Step 3
7. Prints the user’s receipt using the function from Step 4
Step 6: Submit your program to Canvas.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- For each of the following functions, indicate how much the function’s value will change it its argument is increased Triple. 3Narrow_forward8. Write a function with one parameter. The function should accept the value of a radius as its argument and return the volume of the sphere with that radius. Note that the radius may be a decimal fraction. The function should not read or print anything.arrow_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_forward
- 5 Variables that are declared outside the body of any function are called what?arrow_forwardHere are three versions of a code fragment located inside a function: Version A for Row in range(10): for Column in range(5): DoSomethingInteresting(Row,Column) return Version B for Row in range(10): for Column in range(5): DoSomethingInteresting(Row,Column) return Version C for Row in range(10): for Column in range(5): DoSomethingInteresting(Row,Column) return How many times do each of the versions call the DoSomethingInteresting function? Write a sentence or two explaining which version is the "correct" versionarrow_forward*DONOT USE CHATGPT, please put comments so i can understand. It’s a C language program with algorithm.arrow_forward
- 1. Write function printGrade in void function to compute and output the course grade. The course score is passed as a parameter to the function printGrade. (The program will take 5 inputs for 5 subjects. And show the grade of each subject. And calculate the CGPA) TTTE Percentage Score Quality Point Renark Letter Grade 8e - 100 75 - 79 70- 74 65- 69 6e- 64 55- 59 se - 54 45 - 49 40 - 44 35 - 39 e. 34 Excellent Extrenely Good Very Good Good Fairly Good Satisfactory Quite Satisfactory Poor 4.00 3.67 3.33 3.00 2.67 2.33 2.e0 1.67 1.33 Very Poor Extremely Poor Fail 1.00 Expected Output: Inputs 1. Mark for the programming is: 2. Mark for the Math is: 80 85 3. Mark for the Database System is: 4. Mark for the Software Engineering is: 5. Mark for the Business Fundamental is: 74 76 65 Output Letter Grade for Programming: A Letter Grade for Math: A Letter Grade for Database System: Letter Grade for Software Engineering: Letter Grade for Business Fundamental: Remark: B+ A- в Extremely Good 2.…arrow_forwardExercise 4 A number, a, is a power of b if it is divisible by b and a/b is a power of b. Write a function called is_power that takes parameters a and b and returns True if a is a power of b. Note: you will have to think about the base case.arrow_forward// // 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) { // Insert your code between here and the next comment block. Do not alter // // any code in any other part of this file. // Insert your code between here and the previous comment block. // any code in any other part of this file. Do not alter // // var years = parseInt(prompt('How many years will you work for pennies a day? ')); var totalDollarsEarned = totalEarned (years); alert('Over a total of ' + years + ', you will have earned $' + totalDollarsEarned);arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education