Concept explainers
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
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Java How To Program (Early Objects)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Starting out with Visual C# (4th Edition)
Starting Out With Visual Basic (8th Edition)
Starting Out With Visual Basic (7th Edition)
- 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_forwardDomino'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_forward
- flowchart for this Design a function named FindMax_697 (where 697 is last 3 digits of your student number) that accepts three integer values as arguments and returns the value that is the highest of the three. Prompt the user to enter three integer values in the main program and pass those values to the function. The function must return the greatest value from the three. Thenyour program should display that greatest value.arrow_forwardQuestion 6 # This function checks whether a given number is even or not def isEven(number): """ what it takes? a number what it does? determines if a number is even what it returns? if even, return 1 if odd, return -1 """ # your code goes in here defisEven(number): #check if the number is divisible by 2 by checking the remainder. if number % 2==0: #If remainder is 0, then its divisble by 2 and an even number #hence return-1 return1 else: #if remainder is not 0, it'll be 1, so its NOT divisible by 2 and its an odd number #hence return -1 return-1 Test case for question 6 try: if isEven(5) == -1: score['question 6'] = 'pass' else: score['question 6'] = 'fail' except: score['question 6'] = 'fail' isEven(5)arrow_forwardhelppp meee Instructions: You are provided with the isLeapYear() function which is already declared and defined for you. Your task is to ask the user for a year and then call the isLeapYear function to check whether the year is a leap year or not. Input 1. Year to be checked Output should be like this: Enter year: 2020 2020 is a leap year note: If a certain year is a leap year, print "<INSERT_YEAR_HERE> is a leap year" Otherwise, print "<INSERT_YEAR_HERE> is not a leap year" MY CODE: (IN C LANGUAGE PLEASE) #include<stdio.h> int isLeapYear(int); int main(void) { // TODO: Write your code here return 0;} int isLeapYear(int n) { if( (n % 4 == 0 && n % 100 != 0) || (n % 100 == 0 && n % 400 == 0) ) { return 1; } return 0;}arrow_forward
- Given: 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 program that prompts the user to enter a number of feet and then displays the number of inches in that many feet. Draw your Flowchart using the pseudocode below: function inches=feetToInches(feet) prompt='enter the value of feet in digits'; feet=input(prompt)% ask for the value in feet that needs to be converted to inches inches =feet*12; % converts feet to inches x=['the value in inches is: ',num2str(inches)]; disp(x) %display the result of the convertion endarrow_forwardFuture Investment Value = investment amount * (1 + monthly interest)^(number of years * 12) Using this formula, write a function in Python called futureValue that prompts the user to enter an investment amount, an annual percentage interest rate, and the amount of years. The function should accept the input as arguments. The interest rate should have a default value of 7%. You can add default values of your choice for the amount of years. This function should print out a table that displays the future values. Demonstrate this function in another function called main. Format your output by two decimal places. Output Example: Enter the amount you want to invest: 1000 [Enter] Enter the interest rate for your investment: [Enter] Enter the number of years you want to invest this money: 30 [Enter] Years Future Value 1 1093.81 2 1196.41 ........ 30 14730.58arrow_forwardTask Two Design and develop a function that asks the user to enter a number and save it as the variable "flag". Design and develop another function that uses "flag" and output count numbers from 1 to that number. In the main program demonstrate the use of the two functions.arrow_forward
- When you try to access to a local variable outside the function an error is generatedSelect one:a. Falseb. Truearrow_forwardshipping company uses the following function to calculate thecost (in dollars) of shipping based on the weight of the package (in pounds).Write a program that prompts the user to enter the weight of the package anddisplay the shipping cost. If the weight is greater than 20, display a message “the package cannot be shipped.”arrow_forwardSnowball fight Write a programto calculate the volume of snow needed for a snowball fight. Use separate functions to: Print directions / an intro message to the user. Read the number of snowballs from the user. Calculate the volume of a snow required for the snowballs, in cubic feet. Use a constant of 4 inches for the diameter. Print the snowball size, number of snowballs and volume of snow needed. Use 1 decimal place for the snowball size and snow volume. Youroutput should be nicely formatted, with units. Complete the CSC 150 Design Document for your program. Draw a Structure Chart in the space at the top of the document. Below, give the prototype and a brief description for each function. The space in between is for the variables that you're defining in 'main'. It's helpful to list these before you write your function prototypes. A blank design document is available in the Content and Drop box tools. Submit your completed Design Document in the Program3 Design drop box by the due…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning