Есть ответ 👍

Программирование на языке java. лабораторная работа.

a. определить, является ли сумма цифр числа «n» двузначным числом.

б. составить алгоритм, который, зависимо от порядкового номера месяца (1, ), определяет время года, к которому относится этот месяц.

в. определить, являются ли первая и вторая цифры числа «n» цифрой «a».

г. известны год, номер месяца и день рождения каждого из двух людей. определить, кто из них старше.

139
316
Посмотреть ответы 2

Ответы на вопрос:


для в допустим, что слева направо.

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.(h2.;

}

 

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));

}

}


40*1024=

Популярно: Информатика