odin2323
16.01.2023 05:57

Write the classes as shown in the following class diagram. Mark all the overridden methods with annotation @Override. ExerciseOOP_Point2DPoint3D.png
Hints:
You cannot assign floating-point literal say 1.1 (which is a double) to a float variable, you need to add a suffix f, e.g. 0.0f, 1.1f.
The instance variables x and y are private in Point2D and cannot be accessed directly in the subclass Point3D. You need to access via the public getters and setters. For example,
public void setXYZ(float x, float y, float z) {
setX(x); // or super.setX(x), use setter in superclass
setY(y);
this.z = z;
}
The method getXY() shall return a float array:
public float[] getXY() {
float[] result = new float[2]; // construct an array of 2 elements
result[0] = ...
result[1] = ...
return result; // return the array

Нажмите на рекламу ниже и сразу увидите ответ
↓
Популярные вопросы:
Ответ:
emilityan
09.10.2021 21:08
# Код на ruby 2.2.3p173
def zadanie(jump1, jump2)
    min = jump1
    for i in 1..1000
        next if (i*jump1)%jump2 == 0 or (i*jump2)%jump1 == 0

        if min > (i*jump1)%jump2
            min = (i*jump1)%jump2
            p [min, "#{i} * #{jump1} - #{i*jump1/jump2} * #{jump2}"]
        end

        if min > (i*jump2)%jump1
            min = (i*jump2)%jump1
            p [min, "#{i} * #{jump2} - #{i*jump2/jump1} * #{jump1}"]
        end
    end
    return min
end
# # Примеры применения
p zadanie(33, 55)

Вывод
[22, "1 * 55 - 1 * 33"]
[11, "2 * 33 - 1 * 55"]
11

Т.е. минимум при 2 * 33 - 1 * 55 = 11
0,0(0 оценок)
Ответ:
nazar6082005
30.07.2021 08:23
1)
 var 
n:integer;
begin 
readln(n); 
if(n<0)then write(0) 
else write(n+4);
end.

2)
 var
  a, b: integer;
 begin
  readln(a, b);
  if(a = b) then
write(1)
  else
write(0);
end.

3)
var
  a, b, c, s: integer;
 begin
  s := 0;
  readln(a, b, c);
  if(a >= 0) then s := s + 1;
  if(b >= 0) then s := s + 1;
  if(c >= 0) then s := s + 1;
  write(s);
end.

4)
var
  a, b, c, s: integer;
 begin
  s := 0;
  readln(a, b, c);
  if(a > 0) then s := s + a;
  if(b > 0) then s := s + b;
  if(c > 0) then s := s + c;
  write(s);
end.
5)
 var
  a, b, c: integer;
 begin
  readln(a, b, c);
  if (a < b) then swap(a, b);
  if (a < c) then swap(a, c);
  if (b < c) then swap(b, c);
  write(a, ' ', b, ' ', c);
end.

6)
 var n, k, s, i: integer;
 begin
  s := 0;
  readln(n, k);
  for i := 1 to n.ToString.Length do
  if(strtoint(n.ToString[i]) > k) then s := s + strtoint(n.ToString[i]);
  write(s);
 end.

7)
 var n, s, i: integer;
 begin
  s := 0;
  readln(n);
  for i := 1 to n do
    s := s + i;
  write(s);
 end.

9)
 var n, i: integer;
 begin
  readln(n);
  for i := n downto 1 do
  write(i);
 end.

12
 var
  n, i: integer;
  s: real;
 begin
  s := 0;
  readln(n);
  for i := n downto 1 do
  s:=s+(0.1*i);
    write(s);
 end.

13)
 var n, i: integer;
 begin
  readln(n);
  for i := 1 to n do
    write(sqr(i), ' ');
end.

14)
 var
  n, i, c: integer;
 begin
  i := 1;
  c := 0;
  readln(n);
  while (c <> n) do
  begin
    if(i mod 3 = 0) then begin write(i, ' ');c := c + 1; end;
    i := i + 1;
  end;
end.

15)
 var
  n, i, a: integer;
  c: real;
 begin
  i := 1;
  c := 0;
  readln(n);
  for i := 1 to n do
   begin
    read(a);
    c := c + a;
  end;
  write(c / n)
end.

16)
 var
  n, i, a: integer;
 begin
  i := 1;
  while true do
   begin
    read(a);
    if(a = 0) then break;
    n := n + 1;
  end;
  write(n)
end.
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота