Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi can I please get help with making a more functioning code for my assignment Airgead Banking wants a screen to display with the following

Hi can I please get help with making a more functioning code for my assignment 

Airgead Banking wants a screen to display with the following information:  Initial Investment Amount: The starting amount of your investment (a positive real number)  Monthly Deposit: The amount you plan to contribute to the growth of your investment each month (a positive real number)  Annual Interest (Compounded): Interest that is added to the principal sum of your investment and its previously accumulated interest (interest on interest and principal)  Number of Years: The number of years your investment has to grow  A way to see the data (for example: "Press any key to continue...") When the user continues, the console should display two static reports. One should show the year-end balances and year-end earned interest if no additional monthly deposits are made. The second should show the year-end balances and year-end earned interest based on the monthly deposit value that was input by the user ($50.00 in this example). The following is an example of what your interface might look like. It is in no way representative of what it must look like. Be creative and keep the user experience in mind when designing your solution. The user should be able to test different monthly deposit amounts, interest rates, and lengths of time to see how increases and decreases impact their investment growth. Your code will need to account for the following: a. Month: The number of months based on user input in the "Number of Years" field b. Opening Amount: The initial investment amount as well as the opening balance each month, which includes interest c. Deposited Amount: The dollar amount the user plans to deposit each month. This value will be the same every month for the duration of the investment. d. Total: The sum of the opening and deposited amounts e. Interest: Money earned based on the "annual interest" rate input by the user. The interest based on an opening amount of $1 and a deposited amount of $50 with an interest rate of 5% compounded monthly is: (Opening Amount + Deposited Amount) * ((Interest Rate/100)/12) OR (1 + 50) * ((5/100)/12) Note: Dividing by 100 converts the interest rate percentage to a decimal. Note: 12 is the number of months in a year. Dividing the yearly amount by twelve gives monthly compounded interest. f. Closing Balance: The sum of the total and interest amounts As an example, this chart illustrates how compound interest is calculated based on an initial investment amount of $1.00 with additional monthly deposits of $50.00 at 5% interest over 5 years. 

having a hard time getting the user input to calculate properly

#include #include

using namespace std;

int main() { double investAmount = 0.0; double mthDep = 0.0; double annInt = 0.0; int numOfYrs = 0; int optionNumber;

// Display the menu cout << "Calculate how your investment will grow!" << endl;

cout << "1 Initial Investment:" << endl; cout << "2 Monthly Deposit:" << endl; cout << "3 Annual Interest Rate:" << endl; cout << "4 Number of Years:" << endl; cout << "5 Exit" << endl;

cout << "Option: "; cin >> optionNumber;

switch (optionNumber) { case 1: cout << " Initial Investment:$ "; cin >> investAmount; break; case 2: cout << " Monthly Deposit:$ "; cin >> mthDep; break; case 3: cout << " Annual Interest Rate: "; cin >> annInt; break; case 4: cout << "Number of Years: "; cin >> numOfYrs; break; case 5: // Calculate Future Value { double futureValue = investAmount; for (int i = 0; i < numOfYrs; i++) { futureValue += mthDep * 12; // Add yearly deposits futureValue *= (1 + (annInt / 100)); // Apply interest } cout << "Future Value: $" << futureValue << endl; break; } case 6: // Calculate Total Deposits { double totalDep = investAmount + (mthDep * 12 * numOfYrs); cout << "Total: $" << totalDep << endl; break; } case 7: // Calculate Total Interest Earned { double totalDep = investAmount + (mthDep * 12 * numOfYrs); double totalInt = (investAmount + (totalDep * 0.5)) - totalDep; cout << "Total Interest: $" << totalInt << endl; break; } case 8: cout << "Exit" << endl; break; }

// Pause to allow the user to read the message cout << "Press any key to continue..."; cin.ignore(); cin.get();

// Principal amount (initial balance) double principal = 1000.0; // Replace with your initial balance

// Annual interest rate (as a decimal) double annualInterestRate = 0.05; // Replace with your annual interest rate

// Number of years to calculate int numberOfYears = 5; // Replace with the number of years you want to calculate

// Loop through each year for (int year = 1; year <= numberOfYears; year++) { // Calculate year-end balance and earned interest double yearEndBalance = principal * pow(1 + annualInterestRate, year); double earnedInterest = yearEndBalance - principal;

// Output results cout << "Year: " << year << endl; cout << "Year-End Balance: $" << yearEndBalance << endl; cout << "Year-End Earned Interest: $" << earnedInterest << endl;

// Update principal for the next year principal = yearEndBalance; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions