Skip to content

Instantly share code, notes, and snippets.

@ValdemarK
Forked from OlexsandrZ/Ex1
Created October 26, 2016 20:23
Show Gist options
  • Save ValdemarK/7bb829ee3de9c4ee04e18e05660a2d9a to your computer and use it in GitHub Desktop.
Save ValdemarK/7bb829ee3de9c4ee04e18e05660a2d9a to your computer and use it in GitHub Desktop.
Home work#2 Заїка Олександр
package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int a;
Scanner sc = new Scanner(System.in);
System.out.print("Введіть число:");
a = sc.nextInt();
if (a > 0)
if (a % 2 == 0)
System.out.println("even");
else
System.out.println("odd");
else
System.out.println("Число відємне");
}
}
public class While {
public static void main(String[] args) {
int a, i;
Scanner sc = new Scanner(System.in);
a = sc.nextInt();
i =0;
while( i < a )
{
System.out.println("I will adopt best practices");
i++;
}
}
}
package com.company;
public class Chusla {
public static void main(String[] args) {
int a, i;
a = 10;
for (i = 0;i < 10;i++)
{
System.out.println(a + ",");
a-=1;
}
}
}
package com.company;
public class Parni {
public static void main(String[] args) {
int a,i;
a = 0;
for (i = 0; i < 20; i++)
{
a += 1;
if (a % 2 != 0)continue;
System.out.println(a);
}
}
}
public class Zminnni {
public static void main(String[] args) {
int m,n,i;
int a = 0;
Scanner sc = new Scanner(System.in);
System.out.print("Введіть змінну m = ");
m = sc.nextInt();
System.out.print("Введіть змінну n = ");
n = sc.nextInt();
for (i = 0; i < n; i++)
{
a += 1;
if (a % m != 0) continue;
System.out.println(a);
}
}
}
package com.company;
import java.util.Scanner;
public class Tabl {
public static void main(String[] args) {
int a,b,i;
i = 0;
Scanner sc = new Scanner(System.in);
System.out.print("Введіть таблицю множення:");
a = sc.nextInt();
while (i <= 10)
{
b = a * i;
System.out.println(a+ "*" +i+ "=" +b );
i++;
}
}
}
package com.company;
import java.util.Scanner;
public class Arufm {
public static void main(String[] args) {
int n,i,a,b;
Scanner sc = new Scanner(System.in);
System.out.print("Введіть останнє число арифметичної прогресії" +":");
n = sc.nextInt();
i = 1;
a = 0;
while (i <= n) {
b = a + i;
i++;
a = b;
}
System.out.println("Сума арифметичної прогресії:" +a);
}
}
package com.company;
public class Tablzslesh {
public static void main(String[] args) {
int i,c,a;
a = 1;
i =1;
while (i < 10)
{
c = a * i;
if (a == i)
System.out.print("# |");
else if (c < 10)
System.out.print(c +" |");
else
System.out.println(c+"|");
i++;
}
System.out.println("Табличка множення на:"+a);
a = 2;
i =1;
while (i < 10)
{
c = a * i;
if (a == i)
System.out.print("# |");
else if (c < 10)
System.out.print(c +" |");
else
System.out.print(c+"|");
i++;
}
System.out.println("Табличка множення на:"+a);
a = 3;
i =1;
while (i < 10)
{
c = a * i;
if (a == i)
System.out.print("# |");
else if (c < 10)
System.out.print(c +" |");
else
System.out.print(c+"|");
i++;
}
System.out.println("Табличка множення на:"+a);
a = 4;
i =1;
while (i < 10)
{
c = a * i;
if (a == i)
System.out.print("# |");
else if (c < 10)
System.out.print(c +" |");
else
System.out.print(c+"|");
i++;
}
System.out.println("Табличка множення на:"+a);
a = 5;
i =1;
while (i < 10)
{
c = a * i;
if (a == i)
System.out.print("# |");
else if (c < 10)
System.out.print(c +" |");
else
System.out.print(c+"|");
i++;
}
System.out.println("Табличка множення на:"+a);
a = 6;
i =1;
while (i < 10)
{
c = a * i;
if (a == i)
System.out.print("# |");
else if (c < 10)
System.out.print(c +" |");
else
System.out.print(c+"|");
i++;
}
System.out.println("Табличка множення на:"+a);
a = 7;
i =1;
while (i < 10)
{
c = a * i;
if (a == i)
System.out.print("# |");
else if (c < 10)
System.out.print(c +" |");
else
System.out.print(c+"|");
i++;
}
System.out.println("Табличка множення на:"+a);
a = 8;
i =1;
while (i < 10)
{
c = a * i;
if (a == i)
System.out.print("# |");
else if (c < 10)
System.out.print(c +" |");
else
System.out.print(c+"|");
i++;
}
System.out.println("Табличка множення на:"+a);
a = 9;
i =1;
while (i < 10)
{
c = a * i;
if (a == i)
System.out.print("# |");
else if (c < 10)
System.out.print(c +" |");
else
System.out.print(c+"|");
i++;
}
System.out.print("Табличка множення на:"+a);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment