![Problem Solving with C++ (9th Edition)](https://www.bartleby.com/isbn_cover_images/9780133591743/9780133591743_largeCoverImage.gif)
For each of the following situations, tell which type of loop (while , do-while, or for) would work best:
a. Summing a series, such as 1/2 + 1/3 + 1/4 + 1/5 + ... + 1/10.
b. Reading in the list of exam scores for one student.
c. Reading in the number of days of sick leave taken by employees in a department.
d. Testing a function to see how it performs for different values of its arguments.
![Check Mark](/static/check-mark.png)
Want to see the full answer?
Check out a sample textbook solution![Blurred answer](/static/blurred-answer.jpg)
Chapter 3 Solutions
Problem Solving with C++ (9th Edition)
Additional Engineering Textbook Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
C++ How to Program (10th Edition)
Starting Out with Python (3rd Edition)
Starting Out with Programming Logic and Design (4th Edition)
- There's a chance that the body of a while loop may never execute. True False Question 2 Global variables can be accessed in any function scope but global constants can only be accessed in int main(). True Falsearrow_forwardExercise 3: Write a function fact (n) which returns the factorial of n (n!). Note: n! is undefined for n<0 so just have the function return 0 for n<0.0! Is defined to be equal to 1. Use a loop.arrow_forwardprogram with a function. program with a function.arrow_forward
- Going missing Some calculations involving blank values may give different results to what you might expect. For example, when you pass a blank value into the AND() function, it is treated as TRUE. This is often unhelpful. To make blanks behave in a sensible way in calculations, you must first convert them to be "not available" using NA(). This function takes no inputs, and returns a missing value. To convert a blank value to a missing value, use this pattern. =IF(ISBLANK(cell), NA(), cell) Instruction In column H, use AND() to find women who have kids and get benefits. In column I, convert the blanks in column G to missing values. In column J, again find women who have kids and get benefits, this time using column I rather than G. please show the formula used to "has kids and gets benefits" , "gets benefits with missing values", has kids and gets benefits". Thank you Is non-white Has over 12 years of school? Is married? Has kids? Has young kids? Is head of household? Gets…arrow_forwardUsing MATLAB or Octave Consider the formula for computing the future value of money: Future Value = Investment * (1 + I)^n I = interest rate expressed as a fractional amount per compounding periods (5% would be expressed as .05) n = number of compounding periods (typically monthly or yearly) a. Create a function file called "future_value" with three inputs: investment, interest rate, number of compounding periods. ( see the sample function file with multiple inputs in the overview page) b. In your main program, use this function to calculate the value of a $500 investment in 4 years, with a monthly compounding interest rate of .75%.arrow_forwardWhich of the following statements about testing are always true. A. If a test fails, there must necessarily be a defect in the executed code. B. If a test passes, there cannot be a defect in any code executed by the test, but there could be a defect elsewhere in the function. C. If a test is unsound, that test passing or failing doesn't tell us whether or not a defect exists. D. All of the above are truearrow_forward
- with python do this ( i only need the code, no need for explanation): 5. View user meals and generate health informationWhen the user chooses 5, the first thing that it should do is to check whether the user information is loaded in the program (i.e., check if the user information is passed to the function that generates recipe recommendations). If the user information is not passed to the function (i.e., the user did not chose option 1 before choosing option 4), call the function that allows the user to either load or create a user profile (option 1 from the main menu). Otherwise, perform the following tasks:• First, check the file username-recipes.txt exists, if the file does not exist, ask the user to generate recipes to view their health information, and call the function that allows the user to do so (i.e., call the function that shows choice 2 from the main menu).• If the file username-recipes.txt exists, open it in read mode and retrieve (i.e., read) all the information that…arrow_forwardI am doing a word guessing game where I have created a function that shuffles a word randomly. However, I want to create a function that will act as a clue when the user presses it; it will display the first word of the jumbled word. For example, if the word is - friends, The Jumbled word would be - siedfrn, with the function I already made. However, in order for users to get some help, they can press a number(4), and the needed function will result in the output to be- fiedsrn.arrow_forwardThe following function is designed to determine (the hard way) if a number is prime. What definition for stopNum will complete the function? There are multiple answers that will work in the sense that they will produce the right output. For full marks, your answer must be the one which will both work AND cause the loop to run the FEWEST number of times (thus making the function as fast as possible). def checkPrime(num): factors - [] stopNum = ??? for nn in range (2, stopNum): if num % nn == 0: factors.append (nn) if len(factors): print("The number is composite") else: print("The number is prime")arrow_forward
- Exercise 5 The greatest common divisor (GCD) of a and b is the largest number that divides both of them with no remainder. One way to find the GCD of two numbers is based on the observation that if r is the remainder when a is divided by b, then gcd(a, b) = gcd(b, r). As a base case, we can use gcd(a, 0) = a. Write a function called gcd that takes parameters a and b and returns their greatest common divisor.arrow_forwardUse matlab to determine the answer. Use the function file then call the function to get the answer in a script file.arrow_forwardWrite a program that works with fractions. Your program should be able to add,subtract, multiply, and divide two fractions. Write a separate function for addition,subtraction, multiplication and division. Specifically, your program must request two fractions from the user, getting the numerator and denominator separately for each fraction, and the operation to perform (add, subtract, multiply, or divide).Your program will then compute the resulting fraction, keeping the numerator and denominator separate, and output the result.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
![Text book image](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)