Answer:
Not without first converting them to a numeric type.EchoSquare.java
Here is the program shown the the previous picture. It computes the square of an integer entered (as characters) by the user.
import java.util.Scanner;
class EchoSquare
{
public static void main (String[] args)
{
Scanner scan = new Scanner( System.in );
int num, square; // declare two int variables
System.out.println("Enter an integer:");
num = scan.nextInt();
square = num * num ; // compute the square
System.out.println("The square of " + num + " is " + square);
}
}
Here is a picture of it running:
QUESTION 13:
Do you think that the following input would work with this program?
twelve hundred