CS2400 Lab 2 Solved

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

Rate this product

If statement and validating input, math library, and output formatting.
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
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.

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 <cmath>
double value = pow(2, 5);

  • lab2-vnqgq4.zip