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

This is java program... Please type it and paste it i really need help 2. Write

ID: 3841551 • Letter: T

Question

This is java program... Please type it and paste it i really need help

2. Write a program that reads four integers and prints the sum of their squares.

3. Write a program that reads three floating point numbers and prints the cube of their average

4.Write a program that prints the square of the product. Prompt for and read three integer values and print the square of the product of all the three integers.

5. Write a program that creates and prints a random phone number of the form XXX–XXX–XXXX. Include the dashes in the out- put. Do not let the first three digits contain an 8 or 9 (but don’t be more restrictive than that), and make sure that the second set of three digits is not greater than 655. Hint: Think through the easiest way to construct the phone number. Each digit does not have to be determined separately.

Explanation / Answer

Task1.java

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

/** Java Program to print The sum of Squares of 4 Integers */
package venkanna;
import java.util.Scanner;
public class Task1 {

   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       int sum=0,sqr=0;
       int a[]=new int[4];
       System.out.println("enter any Four integers: ");
       for(int j=0;j<a.length;j++)
       {
       a[j]=sc.nextInt();
       }
       for(int k=0;k<a.length;k++)
       {
           sqr=a[k]*a[k];
           sum=sum+sqr;
       }
       System.out.println("The sum of Squares of 4 Integers are: "+sum);
       sc.close();
   }

}

Task2.java

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

/** Java Program to print The Cube of their Average is: */
package venkanna;
import java.util.Scanner;

public class Task2 {

   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       float sum=0,cube=0,avg;
       float a[]=new float[3];
       System.out.println("enter any Three Floating Numbers: ");
       for(int j=0;j<a.length;j++)
       {
       a[j]=sc.nextFloat();
       sum=sum+a[j];
       }
       avg=sum/3;
       cube=avg*avg*avg;
       System.out.println("The Cube of their Average is: "+cube);
       sc.close();

   }

}

Task3.java

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

/** Java Program to print Squares of all three Integers */
package venkanna;
import java.util.Scanner;

public class Task3 {

   public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);
       int sqr=0;
       int a[]=new int[3];
       System.out.println("enter any Three integers: ");
       for(int j=0;j<a.length;j++)
       {
       a[j]=sc.nextInt();
       }
       for(int k=0;k<a.length;k++)
       {
           sqr=a[k]*a[k];
           System.out.println("The Square Of Number "+a[k]+" is: "+sqr);
       }
       sc.close();

   }

}

Task4.java

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

package venkanna;
import java.util.Random;
public class Task4 {

   public static void main(String[] args) {
     
   Random obj = new Random();
   String phone;
   int n1 = 0;
   int n2 = 0;
   int n3 = 0;
   n1 = obj.nextInt(600) + 100;
   n2 = obj.nextInt(641) + 100;
   n3 = obj.nextInt(8999) + 1000;
   //String string1 = Integer.toString(n1);
   phone = Long.toOctalString(n1);
   System.out.println("The random generated phone number is: " + phone + "-" + n2 + "-" + n3);

   }

}

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