Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am using Notepad++ for java problems (Please type the code in here and show me

ID: 3864021 • Letter: I

Question

I am using Notepad++ for java problems (Please type the code in here and show me the output)

6.7 Financial application compate the future investment value) Wnie a method that computes future investment value at a given interest rate for a specified number of years. The future investment is determined using the formula in Programming Exercise 2.21. Use the following method header public static double futureInvestmentvalueC double investmentAmount, double monthlyInterestRate, int years) For example, futureInvestmentValueCI0000, 0.05/12 returns 12833.59. Write a test program that prompts the user to enter the investment amount (eg 1000 and the interest rale (e g 9%) and prints a lable that displays future value for the years from 1 lo 30, as shown below: The amount invested: 1000 Annual interest rate: 9 Years Future Value 1093.80 1196.41 13467.25 14730.57

Explanation / Answer

1)

MinimumOf3Nos.java

import java.util.Scanner;

public class MinimumOf3Nos {

   public static void main(String[] args) {
       //Declaring variable
       int minimum;
      
       //Scanner object is used to get the inputs entered by the user
       Scanner sc=new Scanner(System.in);
      
       //creating an integer array of size 3
       int[] nos=new int[3];
      
       /* getting the 3 numbers entered by
       * the user and populating them into an array
       */
       for(int i=0;i<3;i++)
       {
           //getting the number entered by the user
           System.out.print("Enter the number "+(i+1)+":");
           nos[i]=sc.nextInt();
       }
       //calling the method by passing the array as input
       minimum=min(nos);
      
       //displaying the minimum of 3 nos
       System.out.println("The minimum of 3 numbers is :"+minimum);

   }

   //This method find the minimum number among 3 numbers
   private static int min(int[] nos) {
       int min=nos[0];
       for(int i=0;i<nos.length;i++)
       {
           if(min>nos[i])
               min=nos[i];
       }
       return min;
   }

}

________________

output:

Enter the number 1:45
Enter the number 2:12
Enter the number 3:99
The minimum of 3 numbers is :12

_______________________

2)

FutureInvestment.java

import java.util.Scanner;

public class FutureInvestment {

   public static void main(String[] args) {
       //Declaring variables
       double investment_amount,interest_rate,futInvestmentValue;
      
       //Scanner class object is used to read the inputs entered by the user
               Scanner sc=new Scanner(System.in);
              
               //Getting the invest amount entered by the user
               System.out.print("Enter Investment amount :");
               investment_amount=sc.nextDouble();
              
               //Getting the interest rate entered by the user
               System.out.print("Enter Interest Rate :");
               interest_rate=sc.nextDouble();
              
               //Displaying every year investment value
               System.out.println("Years Future Value");
               for(int i=1;i<=30;i++)
               {
               //calculating the investment value for every year
               futInvestmentValue = (investment_amount )* Math.pow(1 + (interest_rate/1200),i*12);
              
               //Displaying the investment value
               System.out.printf("%d %.2f",i,futInvestmentValue);
               System.out.println(" ");
               }

   }

}

__________________________________

Output:

Enter Investment amount :1000
Enter Interest Rate :9
Years   Future Value
1   1093.81
2   1196.41
3   1308.65
4   1431.41
5   1565.68
6   1712.55
7   1873.20
8   2048.92
9   2241.12
10   2451.36
11   2681.31
12   2932.84
13   3207.96
14   3508.89
15   3838.04
16   4198.08
17   4591.89
18   5022.64
19   5493.80
20   6009.15
21   6572.85
22   7189.43
23   7863.85
24   8601.53
25   9408.41
26   10290.99
27   11256.35
28   12312.28
29   13467.25
30   14730.58

_____________________

3)

MilliSecondsConverter.java

import java.util.Scanner;

public class MilliSecondsConverter {

   public static void main(String[] args) {
       //Declaring variables
       long millisecs;
       String result;
      
       //Scanner object is used to get the inputs entered by the user
       Scanner sc=new Scanner(System.in);
      
       //getting the milliseconds entered by the user
       System.out.print("Enter the milliseconds :");
       millisecs=sc.nextLong();
      
       //calling the method by passing the no of milliseconds as input
       result=convertMillis(millisecs);
      
       //Displaying the result
       System.out.println("Hrs:Mins:Secs ::"+result);
            

   }

   //This method will convert the Milliseconds to hrs,mins,secs
   private static String convertMillis(long millisecs) {
       long rem;
       long secs,mins,hrs;
       String res="";
       hrs=millisecs/3600000;
       rem=millisecs-(hrs*3600000);
      
       mins=rem/60000;
       rem=rem-(mins*60000);
      
       secs=rem/1000;
       res=hrs+":"+mins+":"+secs;
       return res;
      
   }

}

____________________

Output:

Enter the milliseconds :5500
Hrs:Mins:Secs ::0:0:5

___________________

Output1:

Enter the milliseconds :555550000
Hrs:Mins:Secs ::154:19:10

____________________

4)

AreaOfPentagon.java

import java.util.Scanner;

public class AreaOfPentagon {

   public static void main(String[] args) {
      
       //Declaring variable
       double side;
      
       //Scanner object is used to get the inputs entered by the user
       Scanner sc=new Scanner(System.in);
      
       //getting the length of the side entered by the user
       System.out.print("Enter the side :");
       side=sc.nextDouble();
      
       //calling the method by passing the length of the side as input
       double res=area(side);
      
       //Displaying the area of the pentagon
       System.out.println("The area of the pentagon is :"+res);

   }

//calculating the area of the pentagon
   private static double area(double side) {
       double area;
       area=(5*side*side)/(4*Math.tan(Math.toRadians(180/5)));
       return area;
   }

}

___________________

output:

Enter the side :5.5
The area of the pentagon is :52.04444136781625

__________________

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote