Sale!

CS 2400 Lab #2 Errors &Future Value solved

Original price was: $35.00.Current price is: $30.00. $25.50

Category:

Description

5/5 - (2 votes)

Assignment:
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 (30 points)
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 (70 points)
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.
CS2400 Lab #2 May 21, 2019
Errors & Future Value (100 points) Page 2 of 2
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
Step 4:
Submit your program and lab2Errors.cc to Blackboard under lab2.
Hint: The following will calculate 25:
#include
double value = pow(2, 5);