Concept explainers
The following
#include <iostream>
using namespace std;
void showDollars(double); // Function prototype
int main()
{
double payRate, hoursWorked, wages;
cout ≪ "How many hours have you worked? "
cin ≫ hoursWorked;
cout ≪ "What is your hourly pay rate? ";
cin ≫ payRate;
wages = hoursWorked * payRate;
showDol1ars(wages);
return 0;
}
// You must write the definition of the function showDollars
// here. It should take one parameter of the type double.
// The function should display the message "Your wages are $"
// followed by the value of the parameter. It should be displayed
// with 2 places of precision after the decimal point, in fixed
// notation, and the decimal point should always display.
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Starting Out with C++: From Control Structures through Objects, Brief Version (8th Edition)
Additional Engineering Textbook Solutions
Programming in C
Introduction To Programming Using Visual Basic (11th Edition)
Modern Database Management
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Problem Solving with C++ (10th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
- C++ program Write a function named "reduce" that takes two positive integer arguments (as reference), call them "num" and "denom", treats them as the numerator and denominator of a fraction, and reduces the fraction.The function should return the value 0 (to indicate failure to reduce: if either of the two arguments is zero) and should return the value 1 otherwise.Function Prototype: bool reduce(int & num,int & denom);arrow_forwardIn C Write the function definition of a function named “sale”as follows: The function accepts two arguments of typefloat, one is the item total and the other is the sale taxpercentage (out of 100%). The function should returnthe amount of tax calculated for the purchase.arrow_forwardSolve the problem in C++ (Financial application: compute the future investment value) Write a function that computes future investment value at a given interest rate for a specified number of years. The future investment is determined using the formula in Programming Exercise 2.23. Use the following function header: double futureInvestmentValue( double investmentAmount, double monthlyInterestRate, int years) For example, futureInvestmentValue(10000, 0.05/12, 5) returns 12833.59. Write a test program that prompts the user to enter the investment amount (e.g., 1000) and the interest rate (e.g., 9%) and prints a table that displays future value for the years from 1 to 30, as shown below: The amount invested: 1000 Annual interest rate: 9 Years Future Value 1 1093.80 2 1196.41 ... 29 13467.25 30 14730.57arrow_forward
- When creating function definitions, it is important for a function to receive its input data via its parameters.It is almost always a bad idea for a function that performs calculations to also perform any kind of consoleinput or output. Trip Cost Function: - write a function to help a travel agent calculate the cost of a trip for a family. The tripincludes a flight and some number of nights in a hotel. The hotel sleeps at most 2 people in each room.Write a Python function that takes four parameters as input and RETURNS the total cost of the trip. Thefour parameters should be the airfare per person in dollars, the room cost per night in dollars, the numberof travellers, and the number of nights. - your function should do no console input and no console output. It must receive its inputthrough its parameters and send its output using a return value. Console I/OIn the main part of your program (i.e. NOT inside the function’s body), use console input to get the necessaryvalues needed by…arrow_forwardConsider the following declaration in the main function const int CAR_TYPES =5; double sales [CAR_TYPES]; write the definition of a function named find_largest that finds the largest amount of sales. Please apply proper indentation to your code.arrow_forwardThis is c programming question. Use function please for solving. Question: (The function that returns letter grade according to midterm and final grade) : The function turn_to_letter decides on the letter grade of the student according to the table below from the visa and final grades sent into it and returns it, write it together with a main function which the turn_to_letter function is called and prints the letter equivalent on the screen. - Success score = 40% of midterm + 60% of final, - F for the success score below 50, D for between 50 and 59, C for between 60 and 69, B for between 70 and 79, A for 80 and above.arrow_forward
- in C++ Complete function PrintPopcornTime(), with int parameter bagOunces, and void return type. If bagOunces is less than 2, print "Too small". If greater than 10, print "Too large". Otherwise, compute and print 6 * bagOunces followed by " seconds". End with a newline. Example output for ounces = 7:42 secondsarrow_forwardAdmission Write a C++ program that: Define a void function named Admission() with two parameters. The function accepts two arguments: a student’s high school grade point average (for example, GPA is 3.2) and an admission test score (for example, 83). The function then displays a message “Accepted” if the student has any of the following: A GPA of 3.6 or above and an admission test score of at least 60. A GPA of 3.0 or above and an admission test score of at least 70. A GPA of 2.6 or above and an admission test score of at least 80. A GPA of 2.0 or above and an admission test score of at least 90. If the student does not meet any of the qualifications, the function should display a message “Rejected”. //for example, here is the function header: void admission (double gpa, int score) Write a function prototype statement for function Admission before the main function, and add function definition after the main function in the program. In the main function, prompts user to enter a…arrow_forwardPlaying with Functions: Write a Javascript program to check if the argument passed to any function is a function type or not. I.e. Create a function check which takes a argument and check if that argument is a function or not.arrow_forward
- python question Implement the following:1) Define a function printNames() which with an arbitrary parameter names.2) This function prints all names sent to the function as arguments.3) Call the printNames() function with the arguments "John" and "Jane".4) Call the printNames() function with the arguments "Jack", "Jason", "Jenny", and "Jerry". Make sure to precisely match the output format below.Write your code in the ANSWER area provided below (must include comments if using code is not covered in the course).Example Output ("John" and "Jane" are arguments)JohnJane Example Output ("Jack", "Jason", "Jenny", and "Jerry" are arguments)JackJasonJennyJerryarrow_forward1) Write an iterative function that takes two int type variables named (h) and (k) as the input parameter and calculates the h ** k value and returns the answer. 2) In the main function, take two integers of int type (g) and (b) from the screen. Using the function you created in (1), calculate the value of and print the result on the screen.arrow_forwardC++ The function prototype of a function that recieves two integer values and computes their sum and difference is given as follows: void computeSum (int num1, int num2, int & sum, int & diff); write the statments to call this function to compute and print the sum and the differnce of 167 and 84.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning