Question

Dylan has grandparents who believe in "planning for the future" instead of giving toys for birthdays...

Dylan has grandparents who believe in "planning for the future" instead of giving toys for birthdays and Christmas. Each year from the time Dylan is one year old, the grandparents deposit $10 for each year of his age for both his birthday and Christmas ($10 for each the first year, $20 for each the second year, etc.). Not taking interest into account, how much money will be in Dylan's account at the end of the year in which he turns 21?

(For this problem, it's ok to assume that Dylan's birthday comes before Christmas.)

Write a program for the above scenario that uses a for loop to calculate the answer.

Write a program for the above scenario that uses a while loop to calculate the answer.

Write a program for the above scenario that uses a do...while loop to calculate the answer.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code

Using for loop

#include<iostream>
using namespace std;

int main()
{
   int i, amount=0;

   //using for loop

   for (int i = 1; i <= 21; i++)
   {
       amount += (i * 10);
   }
   cout << "Using for loop" << endl;
   cout << "Dylan's account at the end of the 21 year: $" << amount << endl;

  

   system("pause");
   return 0;
}

output

- x I C:\Users\josee\source\repos\Dylans account after 21 year Debug\Dylans account after 21 year.exe Using for loop Dylanusing while loop

#include<iostream>
using namespace std;

int main()
{
   int i, amount = 0;
   //using while loop
   i = 1; amount = 0;
   while (i <= 21)
   {
       amount += (i * 10);
       i++;
   }

   cout << "\n\nUsing while loop" << endl;
   cout << "Dylan's account at the end of the 21 year: $" << amount << endl;


   system("pause");
   return 0;
}

I C:\Users\josee\source\repos\Dylans account after 21 year Debug\Dylans account after 21 year.exe - x Using while loop Dylausing fo while

#include<iostream>
using namespace std;

int main()
{
   int i, amount = 0;
  
   i = 1; amount = 0;
  

   //using do while
   do
   {
       amount += (i * 10);
       i++;
   } while (i <= 21);
   cout << "\n\nUsing do while loop" << endl;
   cout << "Dylan's account at the end of the 21 year: $" << amount << endl;
   system("pause");
   return 0;
}

output

I C:\Users\josee\source\repos\Dylans account after 21 year Debug\Dylans account after 21 year.exe - x Using do while loop DIf you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.

Add a comment
Know the answer?
Add Answer to:
Dylan has grandparents who believe in "planning for the future" instead of giving toys for birthdays...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • resentation, Neatness, and Organization points (5 points) The recitation instructors will be giving yo score (out...

    resentation, Neatness, and Organization points (5 points) The recitation instructors will be giving yo score (out of 5 points) that reflect how well your presentation, neatness, and organization of your lutions are 1. When Jack started his job working for an industrial manufacturing company, he contributed $220 at the end of each month into a savings account that earned 2.5 % interest compounded monthly for 8 years. At the end of the 8th year, Jack was laid off. To help...

  • Number 16. Chapter 3 Problem Comes from "Starting out with >>> C++ From Control Structures through...

    Number 16. Chapter 3 Problem Comes from "Starting out with >>> C++ From Control Structures through Objects" Ninth Edition. Checking work Programming Challenges 147 16. Senior Citizen Property Tax Madison County provides a $5,000 homeowner exemption for its senior citizens. For example, if a senior's house is valued at $158,000, its assessed value would be $94,800, as explained above. However, he would only pay tax on $89,800. At last year's tax rate of $2.64 for cach $100 of assessed value,...

  • C LANGUAGE. PLEASE INCLUDE COMMENTS :) >>>>TheCafe V2.c<<<< #include ...

    C LANGUAGE. PLEASE INCLUDE COMMENTS :) >>>>TheCafe V2.c<<<< #include <stdio.h> int main() { int fries; // A flag denoting whether they want fries or not. char bacon; // A character for storing their bacon preference. double cost = 0.0; // The total cost of their meal, initialized to start at 0.0 int choice; // A variable new to version 2, choice is an int that will store the // user's menu choice. It will also serve as our loop control...

  • this is all the information given Personal Financial Planning Mini-Case Jeff and Mary Douglas, a couple...

    this is all the information given Personal Financial Planning Mini-Case Jeff and Mary Douglas, a couple in their mid-30s, have two children - Paul age 6 and Marcy age 7. The Douglas' do not have substantial assets and have not yet reached their peak earning years. Jeff is a general manager of a jewelry manufacturer in Providence, RI while Mary teaches at the local elementary school in the town of Tiverton, RI. The family needs both incomes to meet their...

  • Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that...

    Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that will process monthly sales data for a small company. The data will be used to calculate total sales for each month in a year. The monthly sales totals will be needed for later processing, so it will be stored in an array. Basic Logic for main() Note: all of the functions mentioned in this logic are described below. Declare an array of 12 float/doubles...

  • Can you please help me with creating this Java Code using the following pseudocode? Make Change C...

    Can you please help me with creating this Java Code using the following pseudocode? Make Change Calculator (100 points + 5 ex.cr.)                                                                                                                                  2019 In this program (closely related to the change calculator done as the prior assignment) you will make “change for a dollar” using the most efficient set of coins possible. In Part A you will give the fewest quarters, dimes, nickels, and pennies possible (i.e., without regard to any ‘limits’ on coin counts), but in Part B you...

  • Part B. Gross Income Inclusions & Exclusions For each Q-6 through Q-19 below, determine whether the...

    Part B. Gross Income Inclusions & Exclusions For each Q-6 through Q-19 below, determine whether the item described should be INCLUDED IN or EXCLUDED FROM the Gross Income of the taxpayer who receives the item. • Darken Box A on the Scantron sheet if the item should be INCLUDED IN gross income • Darken Box B on the Scantron sheet if the item should be EXCLUDED FROM gross income 6. $25,000 scholarship for tuition and books received by a full-time...

  • Code is in C# Your instructor would like to thank to Marty Stepp and Hélène Martin...

    Code is in C# Your instructor would like to thank to Marty Stepp and Hélène Martin at the University of Washington, Seattle, who originally wrote this assignment (for their CSE 142, in Java) This program focuses on classes and objects. Turn in two files named Birthday.cs and Date.cs. You will also need the support file Date.dll; it is contained in the starter project for this assignment. The assignment has two parts: a client program that uses Date objects, and a...

  • CASE 20 Enron: Not Accounting for the Future* INTRODUCTION Once upon a time, there was a...

    CASE 20 Enron: Not Accounting for the Future* INTRODUCTION Once upon a time, there was a gleaming office tower in Houston, Texas. In front of that gleaming tower was a giant "E" slowly revolving, flashing in the hot Texas sun. But in 2001, the Enron Corporation, which once ranked among the top Fortune 500 companies, would collapse under a mountain of debt that had been concealed through a complex scheme of off-balance-sheet partnerships. Forced to declare bankruptcy, the energy firm...

  • This year Evan graduated from college and took a job as a deliveryman in the city....

    This year Evan graduated from college and took a job as a deliveryman in the city. Evan was paid a salary of $68,500 and he received $700 in hourly pay for part-time work over the weekends. Evan summarized his expenses below: Cost of moving his possessions to the city (125 miles away) Interest paid on accumulated student loans Cost of purchasing a delivery uniform Contribution to State University deliveryman program $1,200 2,840 1,440 1,320 Calculate Evan's AGI and taxable income...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT