C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 6, Problem 6.32E
(Quality Points for Numeric Grades) Write a function qualityPoints that inputs a student’s average and returns 4 if a student’s average is 90-100, 3 if the average is 80 89. 2 it the average is 70-79, 1 if the average is 60-69 and 0 it the average is lower than 60.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
% WRITE CODE BELOW:
% Step 1: Write a function called "collatz" below where you take an input
% n, and if n is odd, return 3*n+1. If n is even, return n/2. (You need to
% compute mod (n, 2) to test for even/odd. If mod(n,2)==1, n is odd,
% otherwise n is even)
Matlab code
(a) Write the following functions and their docstrings:
• between (num1, num2, num3) takes 3 integer arguments and returns True if num2 is between num1
and num3. It is not between them if it is equal to either of the other two. For example, given the
inputs 5, 3 and 0, the value returned should be True. Given the inputs -2, 2 and 2, False should be
returned. Note that there is no restriction that num1 must be less than num3.
• majorityEven (num_list) returns True if more than half of the integers in the num_list are di-
visible by 2, with no remainder, otherwise it returns False. The list can be of any size. Recall that
zero is divisible by 2 with no remainder. For example, the function should return False for the list
[1,2,3,6] (as only two of the four numbers are divisible by 2) and True for the list [0,1,-4] (as
two of the three numbers are divisible by 2).
(b) Generate at least six test cases for each function you wrote in part (a). You may use white-box and/or
black-box test case…
Computer Science
Chapter 6 Solutions
C++ How to Program (10th Edition)
Ch. 6 - Show the value of x after each of the following...Ch. 6 - (Parking Charges) A parking garage charges a...Ch. 6 - Prob. 6.13ECh. 6 - (Rounding Numbers) Function floor can be used to...Ch. 6 - Prob. 6.15ECh. 6 - (Random Numbers) Write statement that assign...Ch. 6 - (Random Numbers) Write a single statement that...Ch. 6 - Prob. 6.18ECh. 6 - Prob. 6.19ECh. 6 - Prob. 6.20E
Ch. 6 - Prob. 6.21ECh. 6 - Prob. 6.22ECh. 6 - Prob. 6.23ECh. 6 - (Separating Digits) Write program segments that...Ch. 6 - (Calculating Number of Seconds) Write a function...Ch. 6 - (Celsius and Fahrenheit Temperature) Implement the...Ch. 6 - (Find the Minimum) Write a program that inputs...Ch. 6 - Prob. 6.28ECh. 6 - (Prime Numbers) An integer is said to be prime if...Ch. 6 - Prob. 6.30ECh. 6 - Prob. 6.31ECh. 6 - (Quality Points for Numeric Grades) Write a...Ch. 6 - Prob. 6.33ECh. 6 - (Guess-the-Number Game) Write a program that plays...Ch. 6 - (Guess-the-Number Game Modification) Modify the...Ch. 6 - Prob. 6.36ECh. 6 - Prob. 6.37ECh. 6 - Prob. 6.38ECh. 6 - Prob. 6.39ECh. 6 - Prob. 6.40ECh. 6 - Prob. 6.41ECh. 6 - Prob. 6.42ECh. 6 - Prob. 6.43ECh. 6 - Prob. 6.44ECh. 6 - (Math Library Functions) Write a program that...Ch. 6 - (Find the Error) Find the error in each of the...Ch. 6 - (Craps Game Modification) Modify the craps program...Ch. 6 - (Circle Area) Write a C++ program that prompts the...Ch. 6 - (pass-by-Value vs. Pass-by-Reference) Write a...Ch. 6 - (Unary Scope Resolution Operator) What’s the...Ch. 6 - (Function Templateminimum) Write a program that...Ch. 6 - Prob. 6.52ECh. 6 - (Find the Error) Determine whether the following...Ch. 6 - (C++ Random Numbers: Modified Craps Game) Modify...Ch. 6 - (C++ Scoped enum) Create a scoped enum named...Ch. 6 - (Function Prototype and Definitions) Explain the...Ch. 6 - Prob. 6.57MADCh. 6 - Prob. 6.58MADCh. 6 - (Computer-Assisted Instruction: Monitoring Student...Ch. 6 - (Computer-Assisted Instruction: Difficulty Levels)...Ch. 6 - (Computer-Assisted Instruction: Varying the Types...
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
- (Numerical) Heron’s formula for the area, A, of a triangle with sides of length a, b, and c is A=s(sa)(sb)(sc) where s=(a+b+c)2 Write, test, and execute a function that accepts the values of a, b, and c as parameters from a calling function, and then calculates the values of sand[s(sa)(sb)(sc)]. If this quantity is positive, the function calculates A. If the quantity is negative, a, b, and c do not form a triangle, and the function should set A=1. The value of A should be returned by the function.arrow_forward(Statics) A beam’s second moment of inertia, also known as its area moment of inertia, is used to determine its resistance to bending and deflection. For a rectangular beam (see Figure 6.6), the second moment of inertia is given by this formula: Ibh3/12 I is the second moment of inertia (m4). b is the base (m). h is the height (m). a. Using this formula, write a function called beamMoment() that accepts two double- precision numbers as parameters (one for the base and one for the height), calculates the corresponding second moment of inertia, and displays the result. b. Include the function written in Exercise 4a in a working program. Make sure your function is called from main(). Test the function by passing various data to it.arrow_forwardTrue or falsearrow_forward
- Do fast i will give u like for surearrow_forwardInstructions: Test each function with a sample output A. The following code in the function "is_prime" attempts to examine a number and return whether the number is prime (i.e. it has no factors besides 1 and itself). It has a "Boolean Flag" called 'prime', however, the boolean logic is not executed correctly, so the function won't always return the right/correct answer. # This function shows an incorrect code for determining whether an integer is prime.def is_prime(n):prime = Truefor i in range(2, n): if n % i == 0: prime = Falseelse: prime = Truereturn prime In what cases does the function report an incorrect answer? How can the code be fixed for it to always report the correct answer? Write your answers as "comments" B. Given the following list, write functions to generate the list comprehensions that would make the following new lists or tuples below function names (respectively): capitalize_first_letter, double_trouble, double_letter # index 0 1 2 3names =…arrow_forwardSee attached photo for prompt: a) Write a Python function called func_xy that takes values x and y as arguments and returns the appropriate value of f(x,y). b) Demonstrate that the function works for all relevant cases by inputting different example values.arrow_forward
- 2. For each of the following functions, indicate how much the function's value will change if its argument is increased fourfold. a) log₂n b) √n c) n²arrow_forwardTaxi Fare Write a function called taxi fare that computes the fare of a taxi ride. It takes two inputs: the distance in kilometers (d) and the amount of wait time in minutes (t). The fare is calculated like this: • the first km is $5 · every additional km is $2 · and every minute of waiting is $0.25. Once a km is started, it counts as a whole (Hint: consider the ceil built-in function). The same rule applies to wait times. You can assume that d >0 and t>= 0 but they are not necessarily integers. The function returns the fare in dollars. For example, a 3.5-km ride with 2.25 minutes of wait costs $11.75. Note that loops and if-statements are neither necessary nor allowed. Function e A Save C Reset I MATLAB Documentation Code to call your function e C Reset 1 fare = taxi_fare(3.5,2.25) > Run Functionarrow_forwardDo not use numpy module or any other module. language:PYTHONarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
functions in c programming | categories of function |; Author: Education 4U;https://www.youtube.com/watch?v=puIK6kHcuqA;License: Standard YouTube License, CC-BY