Concept explainers
The Fibonacci numbers F are defined as follows. F is 1, F is 1, and
Fi+2 = Fi + Fi+1 |
i = 0, 1, 2, … . In other words, each number is the sum of the previous two numbers. The first few Fibonacci numbers are 1, 1, 2, 3, 5, and 8. One place that these numbers occur is as certain population growth rates. If a population has no deaths, then the series shows the size of the population after each time period. It takes an organism two time periods to mature to reproducing age, and then the organism reproduces once every time period. The formula applies most straightforwardly to asexual reproduction at a rate of one offspring per time period.
Assume that the green crud population grows at this rate and has a time period of 5 days. Hence, if a green crud population starts out as 10 pounds of crud, then in 5 days there is still 10 pounds of crud; in 10 days there is 20 pounds of crud, in 15 days 30 pounds, in 20 days 50 pounds, and so forth. Write a
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Problem Solving with C++ (9th Edition)
Additional Engineering Textbook Solutions
Starting Out with Programming Logic and Design (4th Edition)
Starting Out With Visual Basic (7th Edition)
Modern Database Management
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
- Leap years have 366 days (29 Any year that is divisible by 4 but not by 100 is a leap year. If a year is divisible by 400 then it is also a leap year. So in short any year that is divisible by 4 is a leap year, unless it is divisible by 100, in which case it must also be divisible by 400 for it to be a leap year. Example: 1996 and 2000 were leap years, but 1900 was not. days in February).arrow_forward.arrow_forwardInterest on a credit card’s unpaid balance is calculated using the average daily balance. Suppose that netBalance is the balance shown in the bill, payment is the payment made, d1 is the number of days in the billing cycle, and d2 is the number of days payment is made before billing cycle. Then, the average daily balance is: averageDailyBalance = (netBalance * d1 - payment * d2) / d1. The interest on the unpaid balance is: interest = averageDailyBalance * interestRate where interestRate is the interest rate per month. Write a program that accepts as input netBalance, payment, d1, d2, and interestRate. The program outputs the interest. Format your output to two decimal places. Analyze and design this program. Write the code, compile and run it. Upload your analysis and design document and your .cpp source code file here.arrow_forward
- One hundred tickets, numbered 1, 2, 3, . . . , 100, are sold to 100 different people for a drawing.Four different prizes are awarded, including a grand prize. How many ways are there to awardthe prizes if:a) the person holding ticket 35 wins the grand prize?b) the person holding ticket 64 wins one of the prizes?c) the person holding ticket 18 does not win a prize?d) the people holding tickets 30 and 50 both win prizes?arrow_forwardPlease answer it in Python Suppose we play a game where each round takes place in the following way: first, we roll a dice, and its result gives the number of points at stake. Then, the player can, if he wishes, trigger his bonus "double account" or his bonus "triple account". Then, the player answers a number of questions, and calculates his percentage of correct answers. The points awarded to the player for that round are then calculated based on the percentage of correct answers and the number of points in play rounded to the nearest integer (for example, with 50% correct answers and 6 points in play, the player gets 3 points; with 45% correct answers and 8 points in play, the player gets 4 points). Finally, this number of points is possibly multiplied by two or three if the corresponding bonus has been used. Write a function points_match that takes as an argument the percentage, the number of points at stake, and as an optional argument the multiplier (which is worth 2 in a double…arrow_forwardA number of the form a + ib, in which i2 = -1 and a and b are real numbers, is called a complex number. We call the real part and b the imaginary part of a + ib. Complex numbers can also be represented as ordered pairs (a, b). The addition and multiplication of complex numbers are defined by the following rules: (a + ib) + (c + id) = (a + c) + i(b + d ) (a + ib) * (c + id) = (ac - bd) + i(ad + bc) Using the ordered pair notation, these rules are written as: (a, b) + (c, d) = ((a + c), (b + d )) (a, b) * (c, d) = ((ac - bd ), (ad + bc)) C++ has no built-in data type that allows us to manipulate complex numbers. Construct a data type, complex Type, that can be used to process complex numbers. Overload the stream insertion and stream extraction operators for easy input and output. We will also overload the operators + and * to perform addition and multiplication of complex numbers. If x and y are complex numbers, we can evaluate expressions such as x + y and x * y.arrow_forward
- Bowling involves 10 frames. Each frame starts with 10 pins. The bowler has two throws to knock all 10 pins down. The total score is the sum of pins knocked down, with some special rules. For the first 9 frames: If all 10 pins are knocked down on a frame's first throw (a "strike"), that frame's score is the previous frame plus 10 plus the next two throws. (No second throw is taken). If all 10 pins are knocked down after a frame's second throw (a "spare"), that frame's score is the previous frame plus 10 plus the next throw. In the 10th frame, if the bowler's first throw is a strike, or the first two throws yields a spare, the bowler gets a third throw. The 10th frame's score is the previous frame's score plus the pins knocked down in the 10th frame's two or three throws. Given integers represents all throws for a game, output on one line each frame's score followed by a space (and end with a newline). Note that the number of throws may be as few as 11 (strikes in first 9 frames,…arrow_forwardBowling involves 10 frames. Each frame starts with 10 pins. The bowler has two throws to knock all 10 pins down. The total score is the sum of pins knocked down, with some special rules. For the first 9 frames: If all 10 pins are knocked down on a frame's first throw (a "strike"), that frame's score is the previous frame plus 10 plus the next two throws. (No second throw is taken). If all 10 pins are knocked down after a frame's second throw (a "spare"), that frame's score is the previous frame plus 10 plus the next throw. In the 10th frame, if the bowler's first throw is a strike, or the first two throws yields a spare, the bowler gets a third throw. The 10th frame's score is the previous frame's score plus the pins knocked down in the 10th frame's two or three throws. Given integers represents all throws for a game, output on one line each frame's score followed by a space (and end with a newline). Note that the number of throws may be as few as 11 (strikes in first 9 frames,…arrow_forwardQ3: Interplanetary Spaceflight Milan Tusk is the richest person in the universe. After devoting decades of his life to further our space exploration technologies, he’s finally ready to retire. Being a space enthusiast, the first thing he wants to do is visit n planets p1, p2, …, pn, in this order. He’s currently on planet p0. Milan knows that the distance between planets pi and pi + 1 (for 0 ≤ i < n) is d[i]light years. His spaceship uses 1 tonne of fossil fuels per light year. He starts with a full tank and can fill up his tank at any of the n planets (but he must not run out in between two planets). There’s a huge cost to set up the spaceship for refuelling. Due to financial constraints (he’s not THAT rich), he can fill up his tank at most ktimes. In order to save money and make his spaceship lighter, Milan is looking for the smallest possible fuel tank that enables him to complete his space travel and reach planet pn. What is the smallest tank capacity that enables him to do so?…arrow_forward
- The annual rate of inflation is the rate at which money loses its value. For example, if the annual rate of inflation is 3.0%, then in one year it will cost $1030 to buy the goods that could have been purchased for $1000 today. Put another way, a year from now $1000 will only buy 1/1.03 * $1000, or $970.87, worth of goods. Two years from now $1000 will only buy only 1/1.03 of $970.87, or $942.59 worth of goods. Write a program that allows the user to enter an annual rate of inflation between 1% and 15%, and which then reports how much $1000 today will be worth each year for the next 10 years.arrow_forwardLet's begin with a lesson in roulette. Roulette is a casino game that involves spinning a ball on a wheel that is marked with numbered squares that are red, black, or green. Half of the numbers 1–36 are colored red and half are black and the numbers 0 and 00 are green. Each number occurs only once on the wheel. We can make many different types of bets, but two of the most common are to bet on a single number (1–36) or to bet on a color (either red or black). These will be the two bets we will consider in this project. After all players place their bets on the table, the wheel is spun and the ball tossed onto the wheel. The pocket in which the ball lands on the wheel determines the winning number and color. The ball can land on only one color and number at a time. We begin by placing a bet on a number between 1 and 36. This bet pays 36 to 1 in most casinos, which means we will be paid $36 for each $1 we bet on the winning number. If we lose, we simply lose whatever amount of money we…arrow_forwardLet's begin with a lesson in roulette. Roulette is a casino game that involves spinning a ball on a wheel that is marked with numbered squares that are red, black, or green. Half of the numbers 1–36 are colored red and half are black and the numbers 0 and 00 are green. Each number occurs only once on the wheel. We can make many different types of bets, but two of the most common are to bet on a single number (1–36) or to bet on a color (either red or black). These will be the two bets we will consider in this project. After all players place their bets on the table, the wheel is spun and the ball tossed onto the wheel. The pocket in which the ball lands on the wheel determines the winning number and color. The ball can land on only one color and number at a time. We begin by placing a bet on a number between 1 and 36. This bet pays 36 to 1 in most casinos, which means we will be paid $36 for each $1 we bet on the winning number. If we lose, we simply lose whatever amount of money we…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