Java Programming Project: Future Investment Value Calculation

Verified

Added on  2025/04/28

|4
|426
|276
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):
Contents
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
Analysis..................................................................................................................................................3
Design....................................................................................................................................................3
Coding...................................................................................................................................................3
Screenshot of output.............................................................................................................................4
Testing...................................................................................................................................................4
Table of figure
Figure 1: Screenshot of output..............................................................................................................4
Document Page
Analysis
In this assessment, we need to calculate the future investment using the formula which is given in the
assessment for the value for the future investment. The input will be given according to the data type
here in the formula there is the power so to implement that there is need to use the .math library of
java. The input values which user will input they are monthly interest rate amount of investment and
the number of years and the output which this will give is the value of the future investment will be
given to the customer investing money will get the money with many years with the proper interest.
The analysis will be that what type of data type should be given so by analysis all type of data types
there is the result came that the double should be taken.
Design
There is the prototype design before the implementation of the code:
The program will run from top to down by following every step.
There is a number of variables which are defined by each data types.
There is data type double is used because the range of double is more compared to the float
and double is the default variable in java.
For taking the input the Scanner class will be used so that the input can be scanned and can
have the memory space.
As there is the use of power in the formal which was given there is the use of the power
function which is stored in the library of the .math.
After the implementation of the code’s formula and the proper variable are assigned without
the errors will going to give the future investment value.
Coding
import java.util.Scanner;
import java.lang.Math;
public class Main
{
public static void main(String []args)
{
System.out.println("Enter amount for the invesment");
Scanner sc = new Scanner (System.in);
Document Page
double invest_amount=sc.nextDouble();
System.out.println("Enter the intrest rate annual");
double rate_of_interest=sc.nextDouble();
System.out.println("no. of years");
double no_of_year=sc.nextDouble();
double future_investment;
no_of_year= no_of_year*12;
rate_of_interest= (1+ rate_of_interest/100);
rate_of_interest= Math.pow(rate_of_interest,no_of_year);
future_investment= invest_amount * rate_of_interest;
System.out.println("Value" + future_investment);
}
}
Screenshot of output
Figure 1: Screenshot of output
Testing
If the wrong values are inserted then the program will automatically exit by just displaying
the wrong input.
The different values can be calculated to test the efficiency of the code.
chevron_up_icon
1 out of 4
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]