Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int n = 0;
- while (n == 0) {
- System.out.print("Non-Zero digit: ");
- try {
- n = new Integer(in.next());
- }
- catch (Exception e) {
- }
- if (n <= 0) continue;
- }
- in.close();
- int harf;
- if (n % 2 == 0) harf = n / 2;
- else harf = (n + 1) / 2;
- System.out.println("Result: " + harf * harf);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement