-
-
Save FreeFly19/ff1dfdb95ab56de73b93ea62268bfb68 to your computer and use it in GitHub Desktop.
Home work #2
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.company; | |
public class Main { | |
public static void main(String[] args) { | |
int a = 4; | |
if(a % 2 == 0) { | |
System.out.println("even"); | |
} else { | |
System.out.println("odd"); | |
} | |
} | |
} |
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.company; | |
public class Main { | |
public static void main(String[] args) { | |
int a = 1; | |
final int COUNT = 7; | |
while(true){ | |
a++; | |
System.out.println("I will adopt best practices"); | |
if(a>COUNT) break; | |
} | |
} | |
} |
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.company; | |
public class Main { | |
public static void main(String[] args) { | |
int a = 11; | |
while(true){ | |
a--; | |
System.out.print(a+", "); | |
if(a < 1) break; | |
} | |
} | |
} | |
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.company; | |
public class Main { | |
public static void main(String[] args){ | |
for(int i = 0; i <= 20; i = i + 2){ | |
System.out.print(i); | |
System.out.print(" "); | |
} | |
System.out.println(); | |
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.company; | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
Scanner sc1 = new Scanner(System.in); | |
int n = sc1.nextInt(); | |
int m = sc1.nextInt(); | |
int i = 0; | |
while (i < n) { | |
i++; | |
if (i % m == 0) System.out.println(i); | |
} | |
} | |
} | |
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.company; | |
public class Main { | |
public static void main(String[] args){ | |
for(int i = 1; i < 10; i++){ | |
for(int j = 1; j < 10; j++) { | |
System.out.print(i*j); | |
System.out.print("\t"); | |
} | |
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
- |
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
- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment