Created
December 11, 2016 19:40
-
-
Save Banafasto/fa2b689be45416eceee7d5fb71536434 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gmail.kudr641; | |
import java.util.Scanner; | |
public class Example1Chapter3 { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
String one = "***"; | |
String two = "+++"; | |
System.out.println("Input size:"); | |
int size = scanner.nextInt(); | |
scanner.close(); | |
for (int j = 0; j < 5; j++) { | |
for (int i = 0; i < size; i++) { | |
if (i % 2 == 0) { | |
System.out.print(one); | |
} else { | |
System.out.print(two); | |
} | |
} | |
System.out.println(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gmail.kudr641; | |
import java.util.Scanner; | |
public class Example2Chapter3 { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
System.out.println("Input number 4 < n < 16"); | |
int number = scanner.nextInt(); | |
int result = 1; | |
scanner.close(); | |
if (4 > number || number > 16) { | |
System.out.println("Incorrect number"); | |
} else { | |
for (int i = 1; i <= number; i++) { | |
result *= i; | |
} | |
System.out.println("Factorial:" + result); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gmail.kudr641; | |
public class Example3Chapter3 { | |
public static void main(String[] args) { | |
for (int i = 1; i <= 10; i++) { | |
System.out.println(i + " * " + 5 + " = " + (i * 5)); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gmail.kudr641; | |
import java.util.Scanner; | |
public class Example4Chapter3 { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
System.out.println("Input size: "); | |
int size = scanner.nextInt(); | |
scanner.close(); | |
for (int i = 1; i <= size; i++) { | |
for (int j = 1; j <= size; j++) { | |
char let = ' '; | |
if (i == 1 || j == 1 || i == size || j == size) { | |
let = '*'; | |
} else { | |
let = ' '; | |
} | |
System.out.print(let); | |
} | |
System.out.println(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment