MITS4002 Activity 03: Calculating Future Investment Value
VerifiedAdded on 2025/04/28
|4
|455
|206
AI Summary
Desklib provides past papers and solved assignments for students. This project demonstrates calculating future investment value.

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
01. Analysis: We need to develop code in this program for future investment to be printed by
a certain formula. Inputs for this program will be the annual rate, amount of investment
and years. The output will be a future investment. All the variables will be initialized.
02. Design:
The first step was to declare the variables: double amount, double interest_rate,
years and double future_investment for future investment output.
The next step is to declare a feature to generate the output. The formula is used
and the coefficients are replaced with the declared variables to generate the
output.
The next step of the program will be to import the scanner class so that you can
take the input from the user and then create the sc scanner object used for all
variables.
Implement exception handling as an error message can also be shown and the
program continues if a user enters an input that is incorrectly typed.
The program is returned to the main function after exception handling.
03. Coding:
import java.util.InputMismatchException;
import java.util.Scanner;
public class futureinvestmentvalue {
static double amount; //Investment amount
static double interest_rate;// interest rate
static int years;//number of years
static double future_investment=0.0; //future investment amount
public static void main (String[] args) {
try {
Scanner ee= new Scanner (System.in);
System.out.println("Investment amount : ");
double amount1= ee.nextDouble();
System.out.println("Interest rate input : ");
double interest_rate1= ee.nextDouble();
System.out.println("Years input : ");
int years1=ee.nextInt();
System.out.println("Future Investment Value is ");
investment_calculate(amount1, interest_rate1, years1);
}
catch (InputMismatchException e) {
System.out.println("Please numerical value only");
main(null);
Copyright © 2015-2019 VIT, All Rights Reserved. Page 3
01. Analysis: We need to develop code in this program for future investment to be printed by
a certain formula. Inputs for this program will be the annual rate, amount of investment
and years. The output will be a future investment. All the variables will be initialized.
02. Design:
The first step was to declare the variables: double amount, double interest_rate,
years and double future_investment for future investment output.
The next step is to declare a feature to generate the output. The formula is used
and the coefficients are replaced with the declared variables to generate the
output.
The next step of the program will be to import the scanner class so that you can
take the input from the user and then create the sc scanner object used for all
variables.
Implement exception handling as an error message can also be shown and the
program continues if a user enters an input that is incorrectly typed.
The program is returned to the main function after exception handling.
03. Coding:
import java.util.InputMismatchException;
import java.util.Scanner;
public class futureinvestmentvalue {
static double amount; //Investment amount
static double interest_rate;// interest rate
static int years;//number of years
static double future_investment=0.0; //future investment amount
public static void main (String[] args) {
try {
Scanner ee= new Scanner (System.in);
System.out.println("Investment amount : ");
double amount1= ee.nextDouble();
System.out.println("Interest rate input : ");
double interest_rate1= ee.nextDouble();
System.out.println("Years input : ");
int years1=ee.nextInt();
System.out.println("Future Investment Value is ");
investment_calculate(amount1, interest_rate1, years1);
}
catch (InputMismatchException e) {
System.out.println("Please numerical value only");
main(null);
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 (Exception e) {
System.out.println(e);
main(null);
}
}
public static void investment_calculate(double amount, double
interest_rate, int years) {
double future_investment= amount * Math.pow((1+interest_rate/100),
years);
System.out.println(future_investment); // final value print
}
}
04. Output screenshot:
Figure 1: Output screenshot
05. Testing:
Enter the investment amount first; the program continues if the value is of the
correct datatype, and if there is no exception, the program returns to the main
function.
Then enter the interest if the value is of the right datatype then the program will
continue and the program will return to the main function if it is no exception.
The year value will be entered in this step and the handling of exceptions will
again be done to check if there is an exception.
In the end, the input values are passed into the investment value method (amount,
interest_rate, year), and the results are calculated and printed on the screen.
Copyright © 2015-2019 VIT, All Rights Reserved. Page 4
}
catch (Exception e) {
System.out.println(e);
main(null);
}
}
public static void investment_calculate(double amount, double
interest_rate, int years) {
double future_investment= amount * Math.pow((1+interest_rate/100),
years);
System.out.println(future_investment); // final value print
}
}
04. Output screenshot:
Figure 1: Output screenshot
05. Testing:
Enter the investment amount first; the program continues if the value is of the
correct datatype, and if there is no exception, the program returns to the main
function.
Then enter the interest if the value is of the right datatype then the program will
continue and the program will return to the main function if it is no exception.
The year value will be entered in this step and the handling of exceptions will
again be done to check if there is an exception.
In the end, the input values are passed into the investment value method (amount,
interest_rate, year), and the results are calculated and printed on the screen.
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.