Starting from:

$30

CS2400-Lab 2 Errors & Future Value Solved

Step 1: Set up a separate directory for this lab
First log on and open a terminal window to create a separate directory to work on
this lab. Issue the following commands to create a directory:
a. Type cd 2400/Labs
b. Type mkdir lab2
c. Type cd lab2
Step 2: Fixing Programming Errors 
a. Copy the file lab2Errors.cc to the current directory (lab2). The file is
located in /home/nabukama/cs2400/lab2/lab2Errors.cc. Issue the
command:
cp /home/nabukama/cs2400/lab2/lab2Errors.cc lab2Errors.cc
b. Compile the file lab2Errors.cc and fix all the errors in it.
c. Run the program with the input values: 2 3 1. You should get the following
output:
x1 = -0.5
x2 = -1
Step 3: Program 
Write a C++ program that calculates the future value of an investment using
compound interest. The program should ask the user for the investment amount, the
annual interest rate as a percentage, and the time period in years.
Find the future value using the following formula:
������ ����� = ������ � (1 + ��������)56789: ;< =9:?
Display the input data and future values along with the appropriate labels using two decimal
places (see the sample output below).
The program should display an error and terminate if any of the values entered are negative.


Sample input/output:
• Valid Input
Enter the investment amount, the interest, and number of years:
1000.0 10.0 15
Investment Amount: $1000.00
Interest: 10.00%
Number of years: 15.00
Future Value: $4177.25
• Invalid Input
Enter the investment amount, the interest, and number of years:
-1000.00 10.0 15
Error: Invalid Input
• Invalid Input
Enter the investment amount, the interest, and number of years:
1000.00 -10 10
Error: Invalid Input

More products