#first (name display, primitive calculation)
package myNameDisplay;
public class MyNameDisplay {
public static void main(String[] args) {
// String name = "Dimonchik";
// System.out.println(name);
int x = 50;
int y = 8;
System.out.println("Summa = " + (x + y));
System.out.println("Difference = " + (x - y));
System.out.println("Product = " + (x * y));
System.out.println("Division = " + ((double)x / y));
#2 (boolean)
package myNameDisplay;
public class MyNameDisplay {
public static void main(String[] args) {
// String name = "Dimonchik";
// System.out.println(name);
int x1 = 20;
int x2 = 30;
boolean result1 = x1 < x2;
boolean result2 = x1 > x2;
boolean result3 = x1 == x2;
System.out.println("x1 = 20; x2 = 30; So: Yes or Not ? ");
System.out.println("x1 < x2. Smaller? It`s " + result1);
System.out.println("x1 > x2. Bigger? It`s " + result2);
System.out.println("x1 = x2. Equal? It`s " + result3);
}
#3 (if(); and &; or |)
package myNameDisplay;
public class MyNameDisplay {
public static void main(String[] args) {
// String name = "Dimonchik";
// System.out.println(name);
int myMoney = 40;
int ticketPrice = 30;
System.out.println("Will you go?");
/*boolean OKMoney = myMoney >= ticketPrice;
boolean OKFriends = true;
if(OKMoney & OKFriends) {
System.out.println("You`ll go!!!");
}
else {
System.out.println("Sorry, you can`t...");
}*/
boolean OKCash = true;
boolean OKCard = true;
if(OKCash | OKCard) {
System.out.println("You`ll go!!!");
}
else {
System.out.println("Sorry, you can`t...");
}
/*if(myMoney >= ticketPrice) {
if(freeTime) {
System.out.println("You`ll go!!!");
}
else {
System.out.println("Sorry, you can`t...");
}
}
else {
System.out.println("Sorry, you can`t...");
}*/
}
}
#4 practice
package Priamokutnyky;
public class priamokutnykymain {
public static void main(String[] args) {
int ax1 = 2, ay1 = 1, bx1 = 5, by1 = 3;
int ax2 = 7, ay2 = 2, bx2 = 9, by2 = 4;
System.out.println("We`re trying to choose right variant among these 5
ones");
System.out.println("*REMEMBER, allways A-coordinate must be to the left and
below from B-coordinate");
System.out.println("What is type of the cross section of these rectangles?
Let`s check!");
System.out.println("Your coordinates of first rectangle are: A = " + "(" +
ax1 + ";"+ ay1 + ")"+ " ; B = " + "(" + bx1 + ";"+ by1 + ")");
System.out.println("..and second: A = " + "(" + ax2 + ";"+ ay2 + ")"+ " ; B
= " + "(" + bx2 + ";"+ by2 + ")");
if (bx1 < ax2 | bx2 < ax1 | by1 > ay2 | by2 > ay1) {
System.out.println("Oops...There isn`t the cross section");
}
else if ((ax1 == bx2 & ay1 == by2) | (bx1 == ax2 & by1 == ay2)) {
System.out.println("We think..The cross section is a point");
}
else if (ax1 == bx2 | bx1 == ax2) {
System.out.println("We think..The cross section is a vertical line");
}
else if (ay1 == by2 | by1 == ay2) {
System.out.println("We think..The cross section is a horizontal line");
}
else {
System.out.println("We think..The cross section is a rectangle");
}
}
#scanner
import java.util.Scanner;
class first {
public static void main(String[] args) {
Scanner lox = new Scanner(System.in);
System.out.print("What type of lox are you?");
String type = lox.nextLine();
System.out.printf("Go to ass, %s, how much cows have you fucked?",
type);
int cows = Integer.parseInt(lox.nextLine());
System.out.printf("%d is excellent number of funny cows. What are names
of those just-maked-on-troublik cows?", cows);
String names = lox.nextLine();
System.out.printf("%s are good names for their fucking", names);
lox.close();
}
}