MITS4002 Activity 03: Calculating Future Investment Value
VerifiedAdded on 2025/05/01
|5
|392
|394
AI Summary
Desklib provides past papers and solved assignments for students. This project demonstrates building an investment calculator in 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
A. Analysis:
We are about to write a code which will help us in finding the future investment value
with a formula. We are developing a program where the user will be asked to enter
investment amount, number of years & the yearly rate of interest. There is a formula on
the basis of which the output is calculated i.e. the future investment value. The user inputs
and the final answer comes as the output.
B. Design:
1. Firstly, variables which are to be used in the formula will be declared.
2. For the output as the future investment value, a method is developed. The variables
will be inputted in the formula and the investment value will be calculated.
3. Scanner class is used for the input scanning, as the user will enter values used in
the formula to calculate the final answer.
4. For handling the errors if the user inputs wrong values or unexpected values then
an error will be shown otherwise program will run smoothly.
5. The main function will be returned if all the exceptions are properly handled.
C. Coding:
package activty03program;
import java.util.InputMismatchException;
import java.util.Scanner;
public class Activty03program {
static double amount_invested;//Amount to be invested
static double rate_of_interestt;// Interest rate
static int num_of_yrs;//Number of years
public static void final_value(double amount_invested, double
rate_of_interestt, int num_of_yrs)
{
Copyright © 2015-2019 VIT, All Rights Reserved. Page 3
A. Analysis:
We are about to write a code which will help us in finding the future investment value
with a formula. We are developing a program where the user will be asked to enter
investment amount, number of years & the yearly rate of interest. There is a formula on
the basis of which the output is calculated i.e. the future investment value. The user inputs
and the final answer comes as the output.
B. Design:
1. Firstly, variables which are to be used in the formula will be declared.
2. For the output as the future investment value, a method is developed. The variables
will be inputted in the formula and the investment value will be calculated.
3. Scanner class is used for the input scanning, as the user will enter values used in
the formula to calculate the final answer.
4. For handling the errors if the user inputs wrong values or unexpected values then
an error will be shown otherwise program will run smoothly.
5. The main function will be returned if all the exceptions are properly handled.
C. Coding:
package activty03program;
import java.util.InputMismatchException;
import java.util.Scanner;
public class Activty03program {
static double amount_invested;//Amount to be invested
static double rate_of_interestt;// Interest rate
static int num_of_yrs;//Number of years
public static void final_value(double amount_invested, double
rate_of_interestt, int num_of_yrs)
{
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
double answer= amount_invested *
Math.pow((1+rate_of_interestt/100),num_of_yrs);
System.out.println(answer); // future investment value printed.
}
public static void main (String[] args)
{
try
{
Scanner q= new Scanner (System.in);
System.out.println("Amount of Investment = ");
double amount_invested= q.nextDouble();
System.out.println("rate of interest = ");
double rate_of_interestt= q.nextDouble();
System.out.println("no. of years = ");
int num_of_yrs=q.nextInt();
System.out.println("Value of future investment = ");
final_value(amount_invested, rate_of_interestt, num_of_yrs);
}
catch (InputMismatchException cr)
{
System.out.println("Enter numerical.");
main(null);
}
catch (Exception cr)
{
System.out.println(cr);
main(null);
Copyright © 2015-2019 VIT, All Rights Reserved. Page 4
double answer= amount_invested *
Math.pow((1+rate_of_interestt/100),num_of_yrs);
System.out.println(answer); // future investment value printed.
}
public static void main (String[] args)
{
try
{
Scanner q= new Scanner (System.in);
System.out.println("Amount of Investment = ");
double amount_invested= q.nextDouble();
System.out.println("rate of interest = ");
double rate_of_interestt= q.nextDouble();
System.out.println("no. of years = ");
int num_of_yrs=q.nextInt();
System.out.println("Value of future investment = ");
final_value(amount_invested, rate_of_interestt, num_of_yrs);
}
catch (InputMismatchException cr)
{
System.out.println("Enter numerical.");
main(null);
}
catch (Exception cr)
{
System.out.println(cr);
main(null);
Copyright © 2015-2019 VIT, All Rights Reserved. Page 4
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

MITS4002 Activity 03
}}}
D. Output screenshot:
E. Testing:
Testing this program, if it handles exceptions correctly.
Checking each variable, entering the wrong input, for example, entering written number
form, then the program should throw an exception that only numerical values should be
entered.
Copyright © 2015-2019 VIT, All Rights Reserved. Page 5
}}}
D. Output screenshot:
E. Testing:
Testing this program, if it handles exceptions correctly.
Checking each variable, entering the wrong input, for example, entering written number
form, then the program should throw an exception that only numerical values should be
entered.
Copyright © 2015-2019 VIT, All Rights Reserved. Page 5
1 out of 5
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.