Complete the previous
int dayOfWeek(int month, int day, int year);
The function should encapsulate the necessary logic to return the day of the week of the specified date as an int (Sunday = 0, Monday = 1, etc.) You should add validation code to the function that tests if any of the inputs are invalid. If so, the function should return –1 as the day of the week. In your main function write a test driver that checks if dayOfWeek is returning the correct values. Your set of test cases should include at least two cases with invalid inputs.
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Problem Solving with C++ (9th Edition)
Additional Engineering Textbook Solutions
Starting Out with Python (3rd Edition)
C++ How to Program (10th Edition)
Starting Out with C++: Early Objects
Modern Database Management
Database Concepts (7th Edition)
- For the function header below, how many required arguments are there? def mystery_func(input, num, t = 0, x = 10, y = 10) A) 2, B) 1, C) 0, D) 3 For the function header below, how many optional arguments are there? def mystery_func(input, num, t = 0, x = 10, y = 10) A) 3 B) 2 C) 1 D) 0arrow_forwardUsing Python, write an application that will calculate a loan payment. To complete this, you are required to write 2 functions, LoanPayment and InterestOnlyLoanPayment, as well as a test application that calls each of the functions to get the payment amount based on parameters supplied to the functions. The test application should output both the loan payment and the interest-only loan payment based on input values from the user. The LoanPayment function is defined as follows: Payment = Loan amount / Discount factor The discount factor is {[(1 + i)^n] - 1} / [i(1 + i)^n], where you have the following: n = Payments per year × Number of years i = Annual interest rate / Payments per year Take for example the following: D = {[(1 + 0.005)^360] – 1} / [0.005(1 + 0.005)^360] = 166.7916, where n = 12 × 30 and i = 0.06 / 12. Loan payment = $250,000 / 166.7916 = $1,498.88 The InterestOnlyLoanPayment is defined as follows: Interest-only payment = Loan amount × (Annual interest rate / 12) Take…arrow_forwardChange this question to work using a function. decide what the name of the function of each should be, how many parameters are required and what value needs to be returned. You're no longer required to solve the problem - try to re-manage your code to be a function. write a program to prompt to user for hours and rate per hour to compute gross pay. You’ll have to use formatted printing here as well to only display two decimal points. Enter Hours: 35 Enter Rate: 2.75 Pay: $96.25 rate = float (input ("How much do you get paid an hour?")) hours = float(input ("How many hours have you worked?")) print ("Pay: $%.2f"%(rate*hours))arrow_forward
- This question has 2 parts, in part A you will write a function and part B need to implement the function Part A - Write a function called getDistance. This function will have 2 parameters: first is the speed of the object in miles per hour the second is time traveled in hours. The function will return the distance traveld by multiplying the speed by the time passed by parameter. Part B will be a small program that will input the speed and time traveled by 2 vehicles. It will then print which vehicle traveld the furthest and must utilize the function written in part A appropriately. Complete the starter file below (copy and paste into your answer). #write your function here def main(): vehicle1_speed = int(input("Enter the speed of vehicle 1: ")) vehicle1_time = int(input("Enter the time vehicle 1 has traveled: ")) vehicle2_speed = int(input("Enter the speed of vehicle 2: ")) vehicle2_time = int(input("Enter the time vehicle 2 has traveled: "))…arrow_forwardPlease answer it in Python Write a function division_arrondi that takes as an argument a numerator, a denominator, and as optional arguments a rounded Boolean (worth False by default) and a decimal integer (valid 0 by default) and that calculates the value of the numerator/denominator fraction (unless the denominator is zero, in which case your function will display an error message and return nothing). If the rounded Boolean is False, the function will return this result without rounding it (if decimales is specified during the call, it will be ignored). If the rounded Boolean is True, the result will be rounded to the requested number of decimal places (by default, to the nearest integer). To make your rounds, you will use round(nombre_a_arrondir, nombre_de_decimales). Examples:division_arrondi(1,3) is 0.333333333333333333division_arrondi(1,3,rounded=True, decimales=2) is 0.33division_arrondi(15,8) is 1,875division_arrondi(15,8, rounded=True, decimales=2) is 1.88…arrow_forwardPlease answer it in Python Write a function division_arrondi that takes as an argument a numerator, a denominator, and as optional arguments a rounded Boolean (worth False by default) and a decimal integer (valid 0 by default) and that calculates the value of the numerator/denominator fraction (unless the denominator is zero, in which case your function will display an error message and return nothing). If the rounded Boolean is False, the function will return this result without rounding it (if decimales is specified during the call, it will be ignored). If the rounded Boolean is True, the result will be rounded to the requested number of decimal places (by default, to the nearest integer). To make your rounds, you will use round(nombre_a_arrondir, nombre_de_decimales). Examples:division_arrondi(1,3) is 0.333333333333333333 division_arrondi(1,3,rounded=True, decimales=2) is 0.33 division_arrondi(15,8) is 1,875 division_arrondi(15,8, True) is 2 division_arrondi(15,8, rounded=True,…arrow_forward
- Explain the flow of this implemented functions in ++ program, see attached photos for reference. Below are the complete and correct codes, only the explanation of the program flow needed. int quadrant() { int ctr=0; if (x>0 && y >0){ ctr= 1; } else if (x<0 && y >0){ ctr= 2; } else if (x<0 && y <0){ ctr= 3; } else if (x>0 && y <0){ ctr= 4; } else if (y == 0 && x !=0){ ctr = -1; } else if (x == 0 && y !=0){ ctr = -2; } else if (x==0 && y ==0){ ctr = 0; } return ctr; } point* nearer(point* p1, point* p2) { double d1=distance(p1); double d2=distance(p2); if(d1<=d2) return p1; else return…arrow_forwardToll roads have different fees based on the time of day and on weekends. Write a function calc_toll() that has three parameters: the current hour of time (int), whether the time is morning (boolean), and whether the day is a weekend (boolean). The function returns the correct toll fee (float), based on the chart below. Weekday Tolls Before 7:00 am ($1.15) 7:00 am to 9:59 am ($2.95) 10:00 am to 2:59 pm ($1.90) 3:00 pm to 7:59 pm ($3.95) Starting 8:00 pm ($1.40) Weekend Tolls Before 7:00 am ($1.05) 7:00 am to 7:59 pm ($2.15) Starting 8:00 pm ($1.10) Ex: The function calls below, with the given arguments, will return the following toll fees: calc_toll(8, True, False) returns 2.95calc_toll(1, False, False) returns 1.90calc_toll(3, False, True) returns 2.15calc_toll(5, True, True) returns 1.05arrow_forwardUse incremental development to write a function called hypotenuse that returns the length of the hypotenuse of a right triangle given the lengths of the other two legs as arguments. Record each stage of the development process as you go. (Downey, 2015) After the final stage of development, print the output of hypotenuse(3, 4) and two other calls to hypotenuse with different arguments. Include all of the following in your Learning Journal: An explanation of each stage of development, including code and any test input and output. The output of hypotenuse(3,4). The output of two additional calls to hypotenuse with different arguments.arrow_forward
- The goal is to generate digital number signs in Python IDLE. For simplicity, you will use only the numerals 0, 1, and 2, and the signs will be vertical. You will develop a collection of functions that can be used to draw numerals in the format commonly used to digital clocks and other displays. You will build the functions in a systematic way, writing a series of steps that build on one another, so it's important to progress through this assignment in order. Use the indicated function names. # function: horizontal_line# input: a width value (integer)# processing: prints a single horizontal line of the desired size# output: does not return anything# function: vertical_line# input: a shift value and a height value (both integers)# processing: generates a single vertical line of the desired height. the line # is offset from the left side of the screen using the shift value# output: does not return anything# function: two_vertical_lines# input: a width value and a height value (both…arrow_forwardPlease answer it in Python Write an average function that takes as an argument two notes, as well as an optional argument called bonus and whose default value is 0. The function must return the average of the student calculated as follows: first, we calculate the "normal" average between the two grades, then we add the bonus. Be careful, the average returned should not exceed 20, even if the calculation explained above gives a number strictly greater than 20. Examples:average(12,14) is 13.0 average (12,14,1) is 14.0 (because 13 + 1)average(18,19,2) is 20arrow_forwardChange this question to work using a function. decide what the name of the function of each should be, how many parameters are required and what value needs to be returned. You're no longer required to solve the problem - try to re-manage your code to be a function. Write a program to prompt the user for hours and rate per hour to compute gross pay. You will have to use formatted printing here as well to only display two decimal points. Enter Hours: 35 Enter Rate: 2.75 Pay: $ 96.25arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning