Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //By: Sammy Samkough
- import java.util.Scanner;
- public class prompt_integer
- {
- public static void main(String[] args)
- {
- Scanner sc = new Scanner(System.in);
- int num;
- // I made this a do/while loop or it wouldn't be able to compile
- do
- {
- System.out.println("Give me an integer."); // prompt the user
- num = sc.nextInt();
- System.out.println("The squared number of your number is: " + Math.pow(num, 2) + ".\n");
- // I made an if to tell the user that the loop shall be terminated
- if(num == 0)
- {
- System.out.println("You have entered 0 so this loop shall be terminated.");
- }
- }while(num != 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment