Future Investment Value Calculator Project - MITS4002

Verified

Added on  2025/04/28

|4
|332
|309
AI Summary
Desklib provides past papers and solved assignments for students. This project demonstrates calculating future investment value using Java.
Document Page
MITS4002
OBJECT-ORIENTED SOFTWARE
DEVELOPMENT
Activity 03
Project: Calculating Future Investment Value
Student ID:
Student full name:
Total Points (20 pts):
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Contents
Analysis...........................................................................................................................................
Design..............................................................................................................................................
Coding..............................................................................................................................................
Output screenshot............................................................................................................................
Testing.............................................................................................................................................
Copyright © 2015-2019 VIT, All Rights Reserved. Page 2
Document Page
Analysis: We need to develop a code which will take three values as input from the user. These
values will be amount of investment, annual rate of interest, and number of years. The
investment value for the future would be calculated on the basis of the provided formula. The
calculated value will be shown as output to the user.
Design: In order to write the code first of all variables with appropriate datatypes were
declared. The input values were taken from the user with a scanner object called “scn”. The
formula was declared and the final value was calculate using that formula in the print function
itself. The code was put in a try block and exceptions were handled in the catch block to keep the
program running in case of faulty inputs.
Coding:
import java.util.Scanner;
import java.util.InputMismatchException;
public class futureValueCalc {
double output=0.0;
static Scanner scn= new Scanner (System.in);
public static void main (String[] args) {
try {
System.out.println("Input the investment amount: ");
double investment= scn.nextDouble();
System.out.println("Input the rate of interest: ");
double irate= scn.nextDouble();
System.out.println("Input the number of years: ");
int yrs=scn.nextInt();
System.out.println("The accumulated value is: " + investment *
Math.pow((1+irate/100),yrs));
}
catch (InputMismatchException e) {
System.out.println("Only numerical values are allowed");
main(null);
}
catch (Exception e) {
System.out.println(e);
main(null);
}
}
}
Output screenshot:
Copyright © 2015-2019 VIT, All Rights Reserved. Page 3
Document Page
Figure 1: Running Program
Testing:
a. The values provided in the problem statement were entered one by one and the program
returned the correct value.
b. New values were assumed and the future investment for these values was calculated
manually, then these values were fed as input to the program and the program gave the
correct future investment value as output.
Copyright © 2015-2019 VIT, All Rights Reserved. Page 4
chevron_up_icon
1 out of 4
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]