MITS4002 Activity 03: Calculating Future Investment Value using Java
VerifiedAdded on 2025/04/28
|4
|386
|372
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

MITS4002 Activity 03
Copyright © 2015-2019 VIT, All Rights Reserved. Page 2
Copyright © 2015-2019 VIT, All Rights Reserved. Page 2

MITS4002 Activity 03
Analysis- In this program, we need to develop code to be printed by a particular formula for
future investments. The annual rate, amount of investment and years will be the input for this
program. Future investment will be the output.
Design- Declaring the variables which will be then used in the formula of future investment. For
taking input from the user, scanner class will be imported and then sc object will be created
which will take values from the input variable. A future investment function will be created
which will have the formula and all the variables required in the formula will be passed to the
function and final value of a future investment will be printed. For all the errors that might occur,
we will be putting some exception handlings which will be used to handle the error. If there is a
wrong type of input, then the program will return to the main function and if the input is of right
type then it will continue.
Coding-
import java.util.InputMismatchException;
import java.util.Scanner;
public class future_inv_activity3 {
public static void main (String[] args) {
try {
Scanner cs= new Scanner (System.in);
System.out.println("Current Investment = ");
double amount_inv= cs.nextDouble();
System.out.println("Investment rate = ");
double rate_int= cs.nextDouble();
System.out.println("Time in years = ");
int y=cs.nextInt();
System.out.println("Future value of investment = ");
double value_fut_inv= Math.pow((1+rate_int/100),y) * amount_inv;
System.out.println(value_fut_inv);
Copyright © 2015-2019 VIT, All Rights Reserved. Page 3
Analysis- In this program, we need to develop code to be printed by a particular formula for
future investments. The annual rate, amount of investment and years will be the input for this
program. Future investment will be the output.
Design- Declaring the variables which will be then used in the formula of future investment. For
taking input from the user, scanner class will be imported and then sc object will be created
which will take values from the input variable. A future investment function will be created
which will have the formula and all the variables required in the formula will be passed to the
function and final value of a future investment will be printed. For all the errors that might occur,
we will be putting some exception handlings which will be used to handle the error. If there is a
wrong type of input, then the program will return to the main function and if the input is of right
type then it will continue.
Coding-
import java.util.InputMismatchException;
import java.util.Scanner;
public class future_inv_activity3 {
public static void main (String[] args) {
try {
Scanner cs= new Scanner (System.in);
System.out.println("Current Investment = ");
double amount_inv= cs.nextDouble();
System.out.println("Investment rate = ");
double rate_int= cs.nextDouble();
System.out.println("Time in years = ");
int y=cs.nextInt();
System.out.println("Future value of investment = ");
double value_fut_inv= Math.pow((1+rate_int/100),y) * amount_inv;
System.out.println(value_fut_inv);
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

MITS4002 Activity 03
}
catch (InputMismatchException e) {
System.out.println("Enter numeric values only.");
main(null);
}
catch (Exception e) {
System.out.println(e);
main(null);
}}}
Output screenshot-
Testing- It is required as there can be errors in the program. So, testing each variable to check if
the data type is correct or not is important. There are various variables to test on. If the value of
the variable is of correct datatype then the program continues or else it will show an exception
message and return to the main function. Finally, putting all values in the future investment
function and testing it to check if the output is correctly calculated/ printed or not.
Copyright © 2015-2019 VIT, All Rights Reserved. Page 4
}
catch (InputMismatchException e) {
System.out.println("Enter numeric values only.");
main(null);
}
catch (Exception e) {
System.out.println(e);
main(null);
}}}
Output screenshot-
Testing- It is required as there can be errors in the program. So, testing each variable to check if
the data type is correct or not is important. There are various variables to test on. If the value of
the variable is of correct datatype then the program continues or else it will show an exception
message and return to the main function. Finally, putting all values in the future investment
function and testing it to check if the output is correctly calculated/ printed or not.
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.