Can anyone help me to solve this issue . I do not understand where I can put the number of the area. Also what exactly this expression mean:
in.nextInt();
Here is the program:
Write a Java program that reads an integer value representing the side of a square shape and prints out the square’s area and perimeter. Use proper labels for all outputs and comment your code properly.
First of all,
in.nextInt();command means that the programme will allow the user to input an integer number from keyboard. Where asinmeans the Scanner type variable you have declared above your code. As for your code, it probably is :Scanner in=new Scanner(System.in);and
nextInt();means that the allowed input, must be of integer type.You can also give a prompt text from the input by :
Where variable
xis an integer and it will assign the input value by the user.When the programme is executed, it would show this on console :
Hope that works for you, and I guess using
xyou can pretty much write the rest of your code by yourself.