Java Arithmetic Operator calculate on integer

Question

We would like to create a short Java program that uses an x integer and a y integer.

Assign 4 to x and 5 to y.

The code should displays the result of x squared plus y squared.

public class Main {
   public static void main(String[] arguments) {
      //your code here
   }
}


public class Main {
   public static void main(String[] arguments) {
      int x = 4;
      int y = 5;
      int sum = (x*x) + (y*y);
      System.out.println("The result of " + x + " squared plus "
          + y + " squared equals " + sum);
   }
}



PreviousNext

Related