Для В допустим, что слева направо.
class BirthDate{
private int day;
private int month;
private int year;
BirthDate(int day, int month, int year){
this.day = day;
this.month = month;
this.year = year;
}
public int getDay() {
return day;
}
public void setDay(int day) {
this.day = day;
}
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public boolean isOlder(BirthDate bd) {
return this.year >= bd.getYear() && this.month >= bd.getMonth() && this.day > bd.getDay();
}
}
class Human{
private BirthDate birthDate;
private String name;
Human(String name, BirthDate birthDate){
this.birthDate = birthDate;
this.name = name;
}
public BirthDate getBirthDate(){
return this.birthDate;
}
public void setBirthDate(BirthDate bd) {
this.birthDate = bd;
}
public String getName(){
return this.name;
}
public void setName(String name) {
this.name = name;
}
}
public class Task {
private static boolean isSumNumberTwoDecimal(int number) {
int sum = 0;
while(true) {
sum += number % 10;
number /= 10;
if(number < 1) {
break;
}
}
return sum < 100;
}
private static String whichSeason(int month) {
if(month >= 1 && month <= 2 && month == 12) {
return "Winter";
} else if(month >= 3 && month <= 5) {
return "Spring";
} else if(month >= 6 && month <= 8) {
return "Summer";
} else if(month >= 9 && month <= 11){
return "Autumn";
} else {
return "There's no such month";
}
}
private static boolean isSameFirstAndSecond(int number, int numeral){
String sNbr = String.valueOf(number).substring(0, 2);
return Integer.valueOf(sNbr) == numeral;
}
private static boolean isOlder(Human h1, Human h2) {
return h1.getBirthDate().isOlder(h2.getBirthDate());
}
public static void main(String[] args) {
int number = 2939393;
System.out.println(isSumNumberTwoDecimal(number));
//Month and date has correct values
int month = 10;
Human vasya = new Human("Vasya", new BirthDate(1, month, 1990));
Human natalia = new Human("Natalia", new BirthDate(1, month, 1989));
System.out.println(isOlder(vasya, natalia));
System.out.println(whichSeason(month));
System.out.println(isSameFirstAndSecond(number, 29));
}
}
Поделитесь своими знаниями, ответьте на вопрос:
1. выполните действие: а) 1101112 — 101 102; б) 1010012+ 101 102; в) 778 + 748; г) 2a16 + a216.
1) 1000010
2) 1111114
3) 1526
4) 248a
Объяснение:
1,2,3 обычное сложение
4) упрощение
2×а16+а×216
32а+а×216а
32÷216а
248а - подобный член