Concept explainers
Winning Division
Write a
• double getSales () is passed the name of a division. It asks the user for a division’s quarterly sales figure, validates that the input is not less than 0, then returns it. It should be called once for each division.
• void findHighest () is passed the four sales totals. It determines which is the largest and prints the name of the high grossing division, along with its sales figure.
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
STARTING OUT WITH C++ MPL
Additional Engineering Textbook Solutions
Computer Science: An Overview (12th Edition)
C Programming Language
Concepts Of Programming Languages
Web Development and Design Foundations with HTML5 (8th Edition)
Artificial Intelligence: A Modern Approach
C How to Program (8th Edition)
- Function Name: compliments Parameters: answer1 - a boolean (True or False) representing whether the user is "smart" answer2 - a boolean (True or False) representing whether the user is "awesome" answer3 - a boolean (True or False) representing whether the user is "fun" Description: Write a function that outputs a string of compliments based on the adjectives selected by the inputs. Use the inputs True and False. The function should return the string “You are” concatenated with the compliments that are true. The three compliments should be: "smart" "awesome" and "fun". If none of the compliments are true, print the string “Goodbye.” instead. Test Cases: >>>compliments(True, True, True) You are smart awesome fun. >>>compliments(False, True, False) You are awesome. >>>compliments(False, False, False) Goodbye.arrow_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_forwardVoid functions do not return any value when they are called.True or falsearrow_forward
- A 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_forwardA function can return another function. True Falsearrow_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 60-69 D Below 60 F A sample run is as follows: Enter test score 1: 75.0 Enter test score 2: 95.0 Enter test score 3: 80.0 Enter test score 4: 90.0 Enter test score 5: 85.0 Your grades are as follows: Test 1: C Test 2: A Test 3: B Test 4: A Test 5 : Barrow_forward
- Test 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_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_forwardC++ beginnerarrow_forward
- 5. A prime number is a number that is only evenly divisible by itself and 1. For example, the number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, how- ever, is not prime because it can be divided evenly by 1, 2, 3, and 6. Write a Boolean function named is_prime which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Use the function in a program that prompts the user to enter a number then displays a message indicating whether the number is prime. 6. In another program, use the function you wrote in question 5 to print the prime numbers between 1 and 100 using for loop.arrow_forwardTrue/False 10. It's a bad idea to define new functions if it makes a program longer.arrow_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_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr