Concept explainers
Complete the following main function so that it asks for the user's weight (in pounds) and displays the equivalent weight in kilograms.
int main()
{
double pounds, kilograms;
// Write a prompt to tell the user to enter his or her weight
// in pounds.
// Write code here that reads in the user's weight in pounds.
// The following line does the conversion.
kilograms= pounds / 2.2;
// Write code here that displays the user's weight in kilograms.
return 0;
}
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Starting Out With C++: Early Objects, Student Value Edition & Myprogramminglab With Pearson Etext -- Standalone Access Card Package, 9/e
Additional Engineering Textbook Solutions
Artificial Intelligence: A Modern Approach
C How to Program (8th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Starting Out with Java: Early Objects (6th Edition)
- 17. Redo Programming Exercise 16 so that the user can also input the cost of producing one liter of milk and the profit on each carton of milk.arrow_forwardA group of statements, such as the contents of a function, is enclosed inA) Braces {}B) Parentheses ()C) Brackets <>D) All of the above will doarrow_forwardTest Average and Grade Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following functions in the program: calc_average. This function should accept five test scores as arguments and return the average of the scores. determine_grade. This function should accept a test score as an argument and return a letter grade for the score based on the following grading scale: Score Letter Grade 90–100 A 80–89 B 70–79 C 60–69 D Below 60 F Write the following functions: getTestScore(): This function prompts user for five test scores and returns test score to the caller. calcAverage(): This function accepts five test scores as arguments and returns the average of the five test scores. determineGrade(): This function accepts an average as an argument and returns a letter grade for the score based on the grading scale. displayData(): This method displays all five…arrow_forward
- Write the function to print whether number can be divided by 3 on the screen. Print "Can be divided", or "Cannot be divided" on the screen. void PrintDivision(int number) { // write your code here }arrow_forwardA county collects property taxes on the assessment value of property, which is 60 percent of the property’s actual value. For example, if an acre of land is valued at $10,000, its assessment value is $6,000. The property tax is then 72¢ for each $100 of the assessment value. The tax for the acre assessed at $6,000 will be $38.40. Write a function that accepts the actual value of a piece of property and displays the assessment value and property tax. JavaScriptarrow_forwardA particular talent competition has five judges, each of whom awards a score between 0 and 10 to each performer. Fractional scores, such as 8.3, are allowed. A performer’s final score is determined by dropping the highest and lowest score received, then averaging the three remaining scores. Write a C++ program that uses this method to calculate a contestant’s score. It should include the following functions: void getJudgeData(double &, int) should ask the user for a judge’s score, store it in a reference parameter variable, and validate it (do not accept judge scores lower than 0 or higher than 10). This function should be called by the main function once for each of the five judges. void calcScore(double[]) should calculate and display the average of the three scores that remain after dropping the highest and lowest scores the performer received. This function should be called just once by the main function and should be passed the five scores. The two functions,…arrow_forward
- PLEASE MAKE SURE OUTPUT MATCHES THE EXAMPLE PHOTO Write a program that will read in the number of liters of gasoline consumed by the user’s car and the number of miles traveled by the car, and then output the number of miles per gallon the car delivered. Yourprogram should allow the user to repeat this calculation as often as the user wishes. Define a function to compute the number of miles per gallon. Your program should use a globally defined constant for the number of gallons per liter. Note: A liter is 0.264179 gallons. An example run of the program is shown below: Hints:1. What will your function do? Document that in the comment.2. What are the parameter(s) to the function? What type? What type is the returned value?3. What kind of a loop should you use? What’s the minimum number of times the user will go through theloop? How to write a function1) Determine the type and number of parameters2) Determine the type of the return value3) Declare the function (usually at the top of the…arrow_forwardA bank charges $10 per month, plus the following check fees for a commercial checking account: $0.10 each for less than 20 checks $0.08 each for 20 through 39 checks $0.06 each for 40 through 59 checks $0.04 each for 60 or more checks Write a function BankCharges() that allows the user to enter the number of checks written and computes and displays the bank’s service fees for the month. All checks for the month are assigned the same charge, based on the total number of checks written during the month. Use the following test data to determine whether the application is calculating properly. In each case, the customer is charged only a single rate, based on the total number of checks. Your solution should clearly show the function. Customer Number of Checks Bank Charges Nancy 15 Lilian 25 Arianna 45 Ben 75arrow_forwardUsing C Language, write a program. PROGRAMMING EXERCISES 6-5Four track stars have entered the mile race at the Penn Relays. Write a program that scans in the race time in minutes and seconds for a runner and computes and displays the speed in feet per seconds and in meters per seconds. Hint: there are 5280 feet in one mile, and one kilometer equals 3282 feet.Write and call a function that displays instructions to the program users.arrow_forward
- Computer Fundamentals and Programming 2 Write a program that determines a student’s grade. The program will accept 3 scores and computes the average score. Determine the grade based on the following rules: - If the average score is equal or greater than 90, the grade is A. - If the average score is greater than or equal to 70 and less than 90, the grade is B. - If the average score is greater than or equal to 50 and less than 70, the grade is C. - If the average score is less than 50, the grade is F. Source Codes and Print Screen of the Outputarrow_forwardLAB: User-Defined Functions: Miles to track laps One lap around a standard high-school running track is exactly 0.25 miles. Define a function named MilesToLaps that takes a float as a parameter, representing the number of miles, and returns a float that represents the number of laps.Then, write a main program that takes a number of miles as an input, calls function MilesToLaps() to calculate the number of laps, and outputs the number of laps. Ex: If the input is: 1.5 the output is: 6.0 Ex: If the input is: 2.2 the output is: 8.8 Your program should define and call a function: Function MilesToLaps(float userMiles) returns float userLaps Note: Remove all comments outside any functions before running the program.arrow_forwardWrite a program that will read in the number of liters of gasoline consumed by the user’s car and the number of miles traveled by the car, and then output the number of miles per gallon the car delivered. Yourprogram should allow the user to repeat this calculation as often as the user wishes. Define a function to compute the number of miles per gallon. Your program should use a globally defined constant for the number of gallons per liter. Note: A liter is 0.264179 gallons. An example run of the program is shown below: Hints:1. What will your function do? Document that in the comment.2. What are the parameter(s) to the function? What type? What type is the returned value?3. What kind of a loop should you use? What’s the minimum number of times the user will go through theloop? How to write a function1) Determine the type and number of parameters2) Determine the type of the return value3) Declare the function (usually at the top of the program)4) Write the function (usually at the…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning