Brooke is trying to save enough money in the next fifteen months to purchase a plane ticket to Australia. Every month Brooke saves $100. Write a for loop that displays how much money Brooke will save at the end of each month for the next 15 months.

Respuesta :

Answer:

This program required for loop and three variables are declared and initialized. then for loop is use to calculate the saving of 15 months.

The description of each line of code is given below in explanation section. However, it is noted that this program is implemented in C++ programming language using Dev C++.

Explanation:

#include <iostream>

using namespace std;

int main()// program started

{

int totalSaving=0;// total saving at the end of each month  

int monthlySaving=100;// each month saving  

int totalMonth2Save=15;// total month in which he can save

 

for (int i=1; i<=totalMonth2Save;i++)// for loop to count saving for 15 month

{

 totalSaving= totalSaving + monthlySaving;// add the saving of each month into total saving

 

}

cout<<"Total saving at the end of 15th month is ";// display the message  

cout<<totalSaving;//of total 15 month saving  

cout<<"$";// show the currency symbol

 

return 0;

}