Skip to content

Instantly share code, notes, and snippets.

@FreeFly19
Forked from ValeraFITIS/Home work_2
Last active October 23, 2016 21:52
Show Gist options
  • Save FreeFly19/f6c3a1c25438b6b8f23b88f049dcfb33 to your computer and use it in GitHub Desktop.
Save FreeFly19/f6c3a1c25438b6b8f23b88f049dcfb33 to your computer and use it in GitHub Desktop.
package com.company;
public class Home_2_T_1 {
public static void main(String[] args) {
int a = 8;
if (a%2==0) {
System.out.println("even");
} else {
System.out.println("odd");
}
}
}
package com.company;
public class Home_2_T_2 {
public static void main(String[] args){
final int COUNT = 10;
for (int a = 0; a < COUNT; a++) {
System.out.println("A will adopt this practices");
}
}
}
package com.company;
public class Home_2_T_3 {
public static void main(String[] args) {
for (int a = 10; a >= 0; a--) {
if (a == 0) {
System.out.println(a + ".");
} else {
System.out.print(a + ",");
}
}
}
}
package com.company;
public class Home_2_T_4 {
public static void main(String[] args){
for (int a=0; a<=20; a+=2) System.out.print(a+",");
}
}
package com.company;
import java.util.Scanner;
public class Home_2_T_5 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Введите число: ");
int a = scan.nextInt();
System.out.print("Введите число на которое делите: ");
int f = scan.nextInt();
for (int x = 1; x <= a; x++) {
if (x % f == 0) {
System.out.print(x + ",");
}
}
}
}
package com.company;
public class Home_2_T_6 {
public static void main(String[] args) {
for (int a = 1; a < 11; a++) {
System.out.println(" ");
for (int b = 1; b < 11; b++) {
int c = b * a;
System.out.print(c + "\t");
}
}
}
}
package com.company;
import java.util.Scanner;
public class Home_2_T_7 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Введите число :");
int a = scan.nextInt();
int sum = 0;
for (int x = 0; x <= a; x++) {
sum += x;
}
System.out.println("Результат :" + sum);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment