30.4k views
1 vote
Write a program that assigns a value the value of 50000 to an integer variable x, assigns the value of x*x to an integer variable y, and then prints out the value of y.

User Mcot
by
4.8k points

1 Answer

4 votes

Answer:

Step-by-step explanation:

The following code is written in Java and does exactly what the question asks. The variables are long variables instead of integers because integer variables can only be a maximum of 2147483647 and the product of these two variables is much higher than that.

public static void main(String args[]) {

long x = 50000;

long y = x * x;

System.out.println(y);

}

User Deathtiny
by
5.5k points