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

1- Write a program that generates three random integers between 0 and 50, calcul

ID: 639312 • Letter: 1

Question

1- Write a program that generates three random integers between 0 and 50, calculate the average, and prints the result to one decimal place?

2- Write a program that reads two integers from the java console: one representing the number of shots taken by a basketball player, the other representing the number of shots made by the same player. Calculate the shooting percentage and output it with the percent notation .

3- Write a program that takes two number from the java console representing, respectively, an investment and an interest rate (you will expect the user to enter a number such as. 065 for the interest rate, representing a 6.5% interest rate). Your program should calculate and output (in$ notation) the future value of the investment in 5, 10, and 20 years using the following formula.

Please help

Explanation / Answer

//The java program that generages three random values
//and calculates the average value and display one decimal place
import java.util.Random;
public class Average
{
   public static void main(String[] args)
   {
      
       // random integers in [0, 100]
       Random generator = new Random();
        
       //generate threee random numbers between 0 and 50
      
       int random1=generator.nextInt(50);
       int random2=generator.nextInt(50);
       int random3=generator.nextInt(50);

      
      
       //find the average
      
       double average=(random1+random2+random3)/3.0;
      
       System.out.println("Random Number 1: "+random1);
       System.out.println("Random Number 2: "+random2);
       System.out.println("Random Number 3: "+random3);
       System.out.printf("Average %.1f",average);      
   }
}

Sample output:

Random Number 1: 1
Random Number 2: 3
Random Number 3: 15
Average 6.3

--------------------------------------------------------------------------------------------------------
package edu.pitt.is17.your_pitt_id.hw2;


//The java program that prompts for two basket ball shots
//and finds the percentage
import java.util.Scanner;
public class BasketBall
{
   public static void main(String[] args)
   {
      
      
       Scanner reader=new Scanner(System.in);
       System.out.println("Enter number of shots taken by player ");
       double shots1=reader.nextDouble();
      
       System.out.println("Enter number of shots taken by player ");
       double shots2=reader.nextDouble();
      
       double percentage=(shots2/shots1)*100.0;
      
       System.out.printf("Percentage : %.1f %%",percentage);
      
      
   }
}

Sample output:
Enter number of shots taken by player
50
Enter number of shots taken by player
10
Percentage : 20.0 %


------------------------------------------------------------------------------------------------------------------------

The java program that prompts the user to enter the investment
//and rate and calculates the future value for 5 years,10 years
//and 20 years
import java.util.Scanner;
public class Investment
{
   public static void main(String[] args)
   {
      
      
       Scanner reader=new Scanner(System.in);
       System.out.println("Enter investment amount : ");
       double amount=reader.nextDouble();
      
       System.out.println("Enter investment rate( in decimals percentage) : ");
       double rate=reader.nextDouble();
      
      
       //future value for 5 years
       int years=5;
       System.out.println("Future value for 5 years: "+getFutureValue(amount,rate,years));
      
       //future value for 10 years
       years=10;
       System.out.println("Future value for 10 years: "+getFutureValue(amount,rate,years));
      
       //future value for 20 years
       years=20;
       System.out.println("Future value for 20 years: "+getFutureValue(amount,rate,years));
              
   }
  
   //The method accepts the investment ,rate and number of years and returnes
   //the future of the investment
   public static double getFutureValue(double investment,double rate,int years)
   {
       return investment*Math.pow(1+rate/12, 12*years);
   }
      
}
------------------------------------------------------------------------------------
Sample output:
Enter investment amount :
10000
Enter investment rate( in decimals percentage) :
0.065
Future value for 5 years: 13828.17324206292
Future value for 10 years: 19121.83752125049
Future value for 20 years: 36564.46701891031


//Hope this helps you