I am in a college level C++ class and i need help writing a program here it is:
Write an application that calculates the amount of money earned on an investment,
based on an 8 percent annual return. Prompt the user to enter an investment amount and
the number of years for the investment. Do not allow the user to enter a number of years
less than 1 or more than 30. Display the total amount (balance) for each year of the
investment.
if anyone could help i would greatly appreciated i have tried and cant figure it out
// Example program
#include <iostream>
#include <string>
int main()
{
std::string name;
std::cout << "What is your name? ";
getline (std::cin, name);
std::cout << "Hello, " << name << "!\n";
// Put assignment attempt stuff here and resubmit please
}
If you've tried, post your code. (What I think is the)#1 rule of learning anything related to computer science is you can never be afraid of criticism. Also it doesn't hurt to have an iron skin for when someone calls you a f***ing retard because your code is bad. As long as they explain why it's bad.
More often than not, you're gonna want to start thinking about what variables and functions you'll need, followed by constructing some pseudocode. I don't know what you've tried, but I can imagine it goes something like this:
1 2 3
return investPercent*amountOfMoney;
while( 1 <= years <= 30 ) do calculation stuff;
display balance per year;