(You should do the previous two Practice Programs before doing this one.) Write a
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Problem Solving with C++, Student Value Edition
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (8th Edition)
Using MIS (10th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Starting Out With Visual Basic (8th Edition)
Starting Out with Programming Logic and Design (4th Edition)
- 2. Write a program that accepts the price of a meal and the tip percent as a whole number. The program is to compute the tip amount in a separate sub-function, then compute the total amount owed, and finally print out the three amounts in a separate sub-function FORMATTED AS BELOW. Total of sale is: 9999.99 Total tip amount is: 9999.99 Total amount due is: 9999.99arrow_forwardWrite a function that asks the user how many Fibonacci numbers to generate and then generates them. Make sure to ask the user to enter the number of numbers in the sequence to generate. The Fibonacci sequence is a sequence of numbers where the next number in the sequence is the sum of the previous two numbers in the sequence. The sequence looks like this: 1, 1, 2, 3, 5, 8, 13, § You could assign your input integer to a variable num by num = int(input("How many fib. numbers you want to generate?:")). § You have to consider exceptions, such as the input integer is zero, negative numbers or floats. § Please submit your code and console screenshots to Blackboard. Code containing syntax error will be graded zero. § Example: The prompt asks, “How many fib. numbers you want to generate?arrow_forwardIs there a different way to write the same function?arrow_forward
- Answer the following. The correct one in function if the code.arrow_forwardWrite a function that add all odd numbers from 1 to numbers the number is specified in integer parameter number and prints the result?arrow_forwardwrite a function that returns a value to main and identifies if an integer number is odd or even. for example your function could be: int odd_even(int num) { if (num%2==0) return 0; .......arrow_forward
- I have to write three functions, float getNum(), float add(float, float), void outSum(float); that asks user for two numbers, finds the sum of two numbers, and displays the sum repeatly in a main program until the user enter “0” for either one of the numbers. For example, in the main, user enter 2, 4, output sum is 6. Then, 3,7, sum is 10, then 8, 7, sum is 15. When user enter one 0, the repeating process stops. heres what i have for now: #include <iostream> using namespace std; float getNum(){ float x; cout << "Please give me a number: "; cin >> x; float add(float num1, float num2); void outSum(float x); int main() { float num1, num2; num1 = getNum(); num2 = getNum(); outSum(num1); outSum(num2); add(num1, num2); return 0; } float add(float num1, float num2){ return num1 + num2; } void outSum(float x){ }arrow_forward: Write a function that adds two numbers. You should not use+ or any arithmeticoperators.arrow_forwardGiven the following: printf ( “Enter your age in years: “ ); scanf ( “%d”, &age_in_years ); int is_voting_age = ( age_in_years >= 18 ); int is_drinking_age = ( age_in_years >= 21 ); int can_be_president = ( age_in_years >= 35 ); int is_senior_citizen = ( age_in_years >= 65 ); When the age entered is 33, what are the values of the variables above? When the age entered is 12, what are the values of the variables above? Write an IF statement in a function to print ‘Yes’ for each value above that is true.arrow_forward
- Write a program that outputs inflation rates for two successive years and whether the inflation is increasing or decreasing. Ask the user to input the current price of an item and its price one year and two years ago. To calculate the inflation rate for a year, subtract the price of the item for that year from the price of the item one year ago and then divide the result by the price a year ago. Your program must contain at least the following functions: a function to get the input; a function to calculate the results; a function to output the results. Use appropriate parameters to pass the information in and out of the function. An example of the program is shown below: Enter the current price of the item: 10 Enter the price of the item one year ago: 8 Enter the price of the item two years ago: 4 Current year inflation: 0.25 Inflation one year ago: 1.00 Inflation is not increasing.arrow_forwardWrite ONLY the function to do the following: Input a number selected by the user That number MUST be between 10 and 15 The upper and lower range of the answer must be passed as arguments to the function If the number is NOT in the right range, the user MUST be prompted to input the right answer again Return the answer to the calling function when correctarrow_forwardWrite a program that asks the user to input a grade that he or she received on an exam. The grade is an integer between 0 and 100 inclusive. The program should convert the numeric grade into the equivalent letter grade. Do the conversion by using a function Letter_Grade () that converts a numeric grade in the range 0 to 100 to the equivalent letter grade. The function should have one argument, the integer grade. The return value of the function should be A if the grade is 90 to 100; B if the grade is 80 to 89; C if the grade is 70 to 79; D if the grade is 65 to 69; and F if the grade is 64 or lower. After converting the grade, the program should display the nu¬meric grade and the equivalent letter grade.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning