Skip to content

Instantly share code, notes, and snippets.

@Banafasto
Last active December 12, 2016 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Banafasto/aea6e033ccb8e7a4730baa547cacdfad to your computer and use it in GitHub Desktop.
Save Banafasto/aea6e033ccb8e7a4730baa547cacdfad to your computer and use it in GitHub Desktop.
package com.gmail.kudr641;
import java.util.Scanner;
public class Example1Chapter2
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
System.out.println("Input a:");
int max = scanner.nextInt();
System.out.println("Input b:");
int b = scanner.nextInt();
System.out.println("Input c:");
int c = scanner.nextInt();
System.out.println("Input d:");
int d = scanner.nextInt();
scanner.close();
if(max < b){
max = b;
}if(max < c){
max = c;
}if(max < d){
max = d;
}
System.out.println("max: "+max);
}
}
package com.gmail.kudr641;
import java.util.Scanner;
public class Example2Chapter2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the number of the apartment: ");
int number = scanner.nextInt();
scanner.close();
if (number > 144) {
System.out.println("There is no apartments");
}
int access = 1;
int floor = 1;
for (int i = 1; i < number; i += 1) {
if (i % 36 == 0) {
access += 1;
}
if (i % 4 == 0) {
floor += 1;
}
}
floor %= 9;
if (floor == 0) {
floor = 9;
}
System.out.print("Access: " + access + " Floor: " + floor);
}
}
package com.gmail.kudr641;
import java.util.Scanner;
public class Example3Chapter2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Input year: ");
int year = scanner.nextInt();
scanner.close();
String leapYear = "Is leap-year";
if (year % 4 == 0) {
leapYear = "Is leap-year";
}
if (year % 100 == 0) {
leapYear = "Is not leap-year";
}
if (year % 400 == 0) {
leapYear = "Is leap-year";
}
if (year % 4 != 0) {
leapYear = "Is not leap-year";
}
System.out.println(leapYear);
}
}
package com.gmail.kudr641;
import java.util.Scanner;
public class Example4Chapter2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Input a: ");
double a = scanner.nextDouble();
System.out.println("Input b: ");
double b = scanner.nextDouble();
System.out.println("Input c: ");
double c = scanner.nextDouble();
scanner.close();
if(a + b <= c || b + c <= a || a + c <= b){
System.out.println("Is not treangle");
}else{
System.out.println("Is treangle");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment