Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package class170622;
- import java.util.Scanner;
- public class For01 {
- public static void main(String[] args) {
- /*
- * כתוב תוכנית הקולטת מספר ומדפיסה עבור כל מספר את ערכו ואת ערכו הריבועי
- */
- // create a scanner for input data
- Scanner s = new Scanner(System.in);
- // ask user for input data
- System.out.println("Enter integer value: ");
- // get and save input data: integer number
- int n = s.nextInt();
- // close the scanner
- s.close();
- // for each number from 1 to n
- for (int i = 1; i <= n; i += 1) {
- // print to screen the number and its square number
- System.out.printf("n=%d , n^2=%d\n", i, i * i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement