Write a java program to take a value from the user and print the square of it unless it is less than 120. The message "I cannot square number" should appear if the user
assigns the number greater than 120. Using loop
Answers
Answered by
4
Answer:
import java.util.Scanner;
public class Demo {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
System.out.println("Enter a number");
int in = input.nextInt ();
if (in < 120){
int square = in * in;
System.out.println("You entered String " + square);
} else {
System.out.println("I cannot square number");
}
}
}
Explanation:
Cuz thats how it works buddy
Similar questions