Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
5th Edition
ISBN: 9780134801155
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 6, Problem 2PE
Feet to Inches
One foot equals 12 inches. Design a function named feetToInches that accepts a number of feet as an argument, and returns the number of inches in that many feet. Use the function in a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Feet to Inches Problem
One foot equals 12 inches. Use pseudocode to design a function named feetToInches that accepts a number of feet as an argument, and returns the number of inches in that many feet. Use the function in a program that prompts the user to enter a number of feet and then displays the number of inches in that many feet.
FizzBuzz Interview Question
Create a function that takes a number as an argument and
returns "Fizz", "Buzz" or "FizzBuzz".
If the number is a multiple of 3 the output should be "Fizz".
If the number given is a multiple of 5, the output should
be "Buzz".
If the number given is a multiple of both 3 and 5, the output
should be "FizzBuzz".
If the number is not a multiple of either 3 or 5, the number
should be output on its own as shown in the examples below.
The output should always be a string even if it is not a multiple
of 3 or 5.
Examples
fizz_buzz (3)
"Fizz"
fizz_buzz (5) → "Buzz
fizz_buzz (15) "FizzBuzz"
fizz_buzz (4) "4"
11
er 6
Functions
Programming Exercises
te
1. Rectangle Area
ngle Area
The area of a rectangle is calculated according to the following formula:
Area =
Width X Length
Design a function that accepts a rectangle's width and length as arguments and
returns the rectangle's area. Use the function in a program that prompts the user to
enter the rectangle's width and length, and then displays the rectangle's area.
Chapter 6 Solutions
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Ch. 6.1 - How does a function differ from a module?Ch. 6.1 - Prob. 6.2CPCh. 6.1 - Prob. 6.3CPCh. 6.1 - In pseudocode, what does the following statement...Ch. 6.1 - In pseudocode, what does the following statement...Ch. 6.2 - What is the purpose of the Return statement in a...Ch. 6.2 - Look at the following pseudocode function...Ch. 6.2 - What is a Boolean function?Ch. 6 - This is a prewritten function that is built into a...Ch. 6 - This term describes any mechanism that accepts...
Ch. 6 - This part of a function definition specifies the...Ch. 6 - This part of a function definition is comprised of...Ch. 6 - In pseudocode, this statement causes a function to...Ch. 6 - This is a design tool that describes the input,...Ch. 6 - This type of function returns either True or...Ch. 6 - This is an example of a data type conversion...Ch. 6 - Prob. 9MCCh. 6 - Prob. 10MCCh. 6 - The code for a library function must appear in a...Ch. 6 - Prob. 2TFCh. 6 - In many languages it is an error to assign a real...Ch. 6 - In some languages you must use a library function...Ch. 6 - Prob. 5TFCh. 6 - What is the difference between a module and a...Ch. 6 - Prob. 2SACh. 6 - Prob. 3SACh. 6 - Prob. 4SACh. 6 - Prob. 5SACh. 6 - Prob. 6SACh. 6 - As shown in this chapter, write a pseudocode...Ch. 6 - The following pseudocode statement calls a...Ch. 6 - A pseudocode program contains the following...Ch. 6 - Design a pseudocode function named timesTen that...Ch. 6 - Design a pseudocode function named getFirstName...Ch. 6 - Assume that a program has two String variables...Ch. 6 - The programmer intends for this pseudocode to...Ch. 6 - Can you find the reason that the following...Ch. 6 - Can you find the reason that the following...Ch. 6 - Feet to Inches One foot equals 12 inches. Design a...Ch. 6 - Math Quiz Design a program that gives simple math...Ch. 6 - Maximum of Two Values Design a function named max...Ch. 6 - Falling Distance When an object is falling because...Ch. 6 - Kinetic Energy In physics, an object that is in...Ch. 6 - Test Average and Grade Write a program that asks...Ch. 6 - Odd/Even Counter In this chapter you saw an...Ch. 6 - Guess the Number Design a number guessing game...Ch. 6 - Prime Numbers A prime number is a number that is...Ch. 6 - Prime Number List This exercise assumes you have...Ch. 6 - Rock, Paper, Scissors Game Design a program that...Ch. 6 - Prob. 13PECh. 6 - ESP Game Design a program that tests your ESP, or...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What is the output of the following program code? void showVals(double, double); int main() { double x = 1.2, y...
Starting Out with C++: Early Objects (9th Edition)
The thin-walled cylinder can be supported in one of two ways as shown. Determine the state of stress in the wal...
Mechanics of Materials (10th Edition)
Which type of oxyfuel flame is most commonly used?
Degarmo's Materials And Processes In Manufacturing
This optional Google account security feature sends you a message with a code that you must enter, in addition ...
SURVEY OF OPERATING SYSTEMS
True or False: A class may only implement one interface.
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
T F: A local variable may be accessed by any other procedure in the same Form file.
Starting Out With Visual Basic (8th Edition)
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
- 4. During each summer, John and Jessica grow vegetables in their backyard and buy seeds and fertilizer from a local nursery. The nursery carries different types of vegetable fertilizers in various bag sizes. When buying a particular fertilizer, they want to know the price of the fertilizer per pound and the cost of fertilizing per square foot. The following program prompts the user to enter the size of the fertilizer bag, in pounds, the cost of the bag, and the area, in square feet, that can be covered by the bag. The program should output the desired result. However, the program contains logic errors. Find and correct the logic errors so that the program works properly. // Logic errors. #include #include using namespace std; int main() { double costs double area; double bagsize; cout > bagsize; cout > cost; cout > area; cout << endl; cout << "The cost of the fertilizer per pound is: $" << bagsize / cost << endl; cout << "The cost of fertilizing per square foot is: $" << area / cost << endl; return 0; }arrow_forwardThe following statement calls a function named half, which returns a value that is half that of the argument. Write the function named half. result = half(number) %3Darrow_forward# Exercise 8: Create a function that takes the sum of three numbers and returns the value # Make sure to use the function and display the result # When you are done, get 3 numbers from a user and then print out the sum using your functionarrow_forward
- A program contains the following function. int cube(int num) {return num * num * num; }Write a statement that passes the value 4 to this function and assigns its return value to the variable result.arrow_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_forwardTest Average and Grade - MUST BE WRITTEN IN PSEUDOCODEarrow_forward
- Domino's Time Function Name: dominosTime() Parameters: N/A Returns: None Description: During the summer, you ordered a lot of food from Domino's. Pizzas are $12, an order of pasta is $6, and chicken wings are $8. Write a function that asks the user how many of each food item they would like, and then print a response telling them what their order to- tal will be. The order total should be an integer. >>> dominosTime() How many pizzas do you want? 3 How many orders of pasta do you want? 2 How many orders of chicken wings do you want? 2 By ordering 3 pizzas, 2 orders of pasta, and 2 orders of chicken wings, your order total comes to $64.arrow_forwardThe Problem__: Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: ⚫ void getScore() should ask the user for a test score, store it in a reference param- eter variable, and validate it. This function should be called by main once for each of the five scores to be entered. ⚫ void calcAverage() should calculate and display the average of the four highest scores. This function should be called just once by main and should be passed the five scores. ⚫int findLowest() should find and return the lowest of the five scores passed to it. It should be called by calcAverage, which uses the function to determine which of the five scores to drop. Input Validation: Do not accept test scores lower than 0 or higher than 100. YOU MUST USE THE STATED FUNCTIONS AND COMPLETE Input VALIDATION. **DO NOT use an ARRAY OR GLOBAL VARIABLES!!. you MUST USE function prototyping TEST THE FUNCTION TWICE.…arrow_forwardThe following statement calls a function named half, which returns a value that is half that of the argument passed to it. Assume that result and number have both been defined to be double variables. Write the half function. result = half(number);arrow_forward
- program - python Write a program that asks the user to enter four 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 display the letter grade for the score within the function, based on the following grading scale: Score Letter Grade 90–100 A 80–89 B 70–7 9 C 60–69 D Below 60 Farrow_forwardJAVA CODE PLEASE Functions With No Parameters and Return Values Practice ll by CodeChum Admin Create a program that has a global integer variable assigned to a value of 1. Then, create a new function named increment that increments the global variable. In the main function, if the current value of the global variable is divisible by 3, print “Cody!”. Otherwise, print the value of that global variable. Repeatedly call the increment function until the value of the global variable is greater than 15. Output Multiple lines containing a string or an integer 1 2 Cody! 4 5 Cody! 7 8 Cody! 10 11 Cody! 13 14 Cody! Score:arrow_forwardPYTHON PTGRAMMING ONLY NEED HELP MAKING A FLOWCHART TO MATCH MY CODE CODE IS CORRECT JUST NEED HELP AKING TO FLOWCHART QUESTION, CODE, FLOWCHART EXAMPLE PROVIDED QUESTION: Write a function named max that accepts two integer values as arguments and returns thevalue that is the greater of the two. For example, if 7 and 12 are passed as arguments tothe function, the function should return 12. Use the function in a program that prompts theuser to enter two integer values. The program should display the value that is the greaterof the two. MY CODE: # Function to find the maximum of two integersdef maximum(num1, num2):return max(num1, num2)# Function to get integer input from the user with input validationdef get_integer_input(prompt):while True:try:value = int(input(prompt)) # Prompt the user for inputreturn valueexcept ValueError:print("Please enter a valid integer.") # Handle input validation# Main program logicdef main():print("Enter two integer values to find the greater of the…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
functions in c programming | categories of function |; Author: Education 4U;https://www.youtube.com/watch?v=puIK6kHcuqA;License: Standard YouTube License, CC-BY