Future Investment Value Calculator Project - MITS4002
VerifiedAdded 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.

MITS4002
OBJECT-ORIENTED SOFTWARE
DEVELOPMENT
Activity 03
Project: Calculating Future Investment Value
Student ID:
Student full name:
Total Points (20 pts):
OBJECT-ORIENTED SOFTWARE
DEVELOPMENT
Activity 03
Project: Calculating Future Investment Value
Student ID:
Student full name:
Total Points (20 pts):
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

Contents
Analysis...........................................................................................................................................
Design..............................................................................................................................................
Coding..............................................................................................................................................
Output screenshot............................................................................................................................
Testing.............................................................................................................................................
Copyright © 2015-2019 VIT, All Rights Reserved. Page 2
Analysis...........................................................................................................................................
Design..............................................................................................................................................
Coding..............................................................................................................................................
Output screenshot............................................................................................................................
Testing.............................................................................................................................................
Copyright © 2015-2019 VIT, All Rights Reserved. Page 2

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
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
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

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
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
1 out of 4
Related Documents

Your All-in-One AI-Powered Toolkit for Academic Success.
+13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
Copyright © 2020–2025 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.