/**
* Java. Level 1. Lesson 1. Example of homework
*
* @author Sergey Iryupin
* @version dated Nov 25, 2017
*/
class HW1Lesson {
public static void main(String[] args) {
// call for task 2
createVariable();
// call for task 3
System.out.println(calculate(1, 2, 3, 4));
System.out.println(calculate(1, 2, 3, 0));
System.out.println(calculate(1, 2, 0, 0));
// tests for task 4
System.out.println(checkSum(5, 3));
System.out.println(checkSum(10, 5));
System.out.println(checkSum(10, 15));
// tests for task 5
checkPositiveOrNegative(10);
checkPositiveOrNegative(-5);
// tests for task 5
System.out.println(heckNegative(-1));
System.out.println(heckNegative(5));
// call for task 7
welcomeName("World");
// tests for task 8
checkLeapYear(1900); // div 4 but div 100
checkLeapYear(1996); // div 4 and not div 100
checkLeapYear(2000); // div 400
checkLeapYear(2016); // div 4 and not div 100
}
/**
* 2.
* byte, short, int, long, float, double, char, boolean, string
*/
static void createVariable() {
byte b = Byte.MAX_VALUE; // 2^7 - 1
short s = Short.MAX_VALUE; // 2^15 - 1
int i = Integer.MAX_VALUE; // 2^31 - 1
long l = Long.MAX_VALUE; // 2^63 - 1
float f = 123.45F;
double d = 567.89;
char c = 'a';
boolean bool = true;
String str = "Hello";
}
/**
* 3. a * (b + (c / d))
* , a, b, c, d
*/
static double calculate(double a, double b, double c, double d) {
return a * (b + c / d);
}
/**
* 4. , ,
* 10 20 (),
* true, false
*/
static boolean checkSum(int a, int b) {
return ((a + b >= 10) && (a + b