Knowee
Questions
Features
Study Tools

A person saves his monthly saving according to the given schema. He saves the same amount of money which is equal to the money saved in the immediate previous two months. Assume, initially, he saved 1000 rupees and in the first month he saved another 1000. Your task is to tell how much he had totally saved at the end of ‘n’ monthsInput format :The input consists of an integer ‘n’->No. of months.Output format :Print the total savings at the end of ‘n’ months.Sample test cases :Input 1 :1Output 1 :2000Input 2 :3Output 2 :7000

Question

A person saves his monthly saving according to the given schema. He saves the same amount of money which is equal to the money saved in the immediate previous two months. Assume, initially, he saved 1000 rupees and in the first month he saved another 1000. Your task is to tell how much he had totally saved at the end of ‘n’ monthsInput format :The input consists of an integer ‘n’->No. of months.Output format :Print the total savings at the end of ‘n’ months.Sample test cases :Input 1 :1Output 1 :2000Input 2 :3Output 2 :7000

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

This problem can be solved using the concept of Fibonacci series. The savings pattern follows the Fibonacci series where the next number is the sum of the previous two numbers.

Here are the steps to solve this problem:

  1. Initialize three variables, first_month_savings and second_month_savings to 1000 (as given in the problem), and total_savings to 2000 (sum of the first two months' savings).

  2. Start a loop from the third month (i.e., i = 2) up to the nth month.

  3. For each month in the loop, calculate the savings for that month as the sum of the savings of the previous two months. This can be done by adding first_month_savings and second_month_savings.

  4. Update total_savings by adding the savings of the current month.

  5. For the next iteration, update first_month_savings to second_month_savings and second_month_savings to the savings of the current month.

  6. Continue this process until the nth month.

  7. Finally, total_savings will be the total amount saved at the end of n months.

  8. Print total_savings.

This algorithm will give the correct total savings at the end of n months following the given savings pattern.

This problem has been solved

Similar Questions

Tim has just inherited £1000 and he decides not to invest it but rather to spend 10% of the remaining money each month. Each month Tim’s saving thus reduce by a factor of 0.9.Calculate, to the nearest integer, the amount remaining (in £) after 20 months.You may find it useful to first devise a formula for the amount remaining after n months.Enter your answer, to the nearest integer and without units, in the box below.

Suppose you are saving $50 each month. After month 1, you have $50. After month 2, you have $100. After month 3, you have $150. After month 4, you have $200, and this pattern continues. How much money will you have saved after 7 months?

Fin is a financial analyst who needs to verify if the average of three monthly expenses is less than the two smallest monthly expenses. Write a program to calculate this using the conditional operator. The program should output the average value with two decimal places and the two expenses if the average is less than both, along with a corresponding statement.Input format :The first line of input consists of an integer a, representing the first month's expense.The second line consists of an integer b, representing the second month's expense.The third line consists of an integer c, representing the third month's expense.Output format :The first line of output displays the average value in double with two decimal places.The second line of output displays one of the following:If the average is less than the two smallest monthly expenses, print "Average is less than both X and Y " where X and Y are the two smallest expenses.Otherwise, display "Average is not less than both".

Single File Programming QuestionProblem StatementMark wants to calculate his monthly savings based on his salary and a specified savings percentage.Write a program to help Mark that input the monthly salary and the percentage of the salary to save. Use pointers to calculate the amount to save. Display the calculated amount with two decimal places.Input format :The first line of input consists of a floating-point value, representing the monthly salary.The second line consists of a floating-point value, representing the savings percentage.Output format :The output prints a floating-point value, representing the calculated savings amount, rounded off to two decimal places.Refer to the sample output for formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:1.00 ≤ monthly salary ≤ 1,00,000.001.00 ≤ percentage ≤ 100.00Sample test cases :Input 1 :10000.5010.75Output 1 :1075.05Input 2 :80575.2514.50Output 2 :11683.41Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.Marks : 10Negative Marks : 0WhitelistSet 1:*

Ivan is putting money into a savings account. He starts with $350 in the savings account, and each week he adds $60.Let S represent the total amount of money in the savings account (in dollars), and let W represent the number of weeks Ivan has been adding money. Write an equation relating S to W. Then use this equation to find the total amount of money in the savings account after 13 weeks.

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.