У меня есть некоторые проблемы с пониманием того, как я должен выполнять метод compute_even в этом упражнении, я надеюсь, что кто -то сможет мне помочь.
Не берите в голову метод compute_odd Я все еще думаю об этом. Напишите метод void под названием select_function, который имеет параметр n типа int. If the value of n is even the method will call the method compute_even passing to it value of the parameter n, else the method will call the method compute_odd passing to it the value of n.
The two methods will print on the console the following sequence:
compute_even: 2, 4, 8, 16, 32, 64, 128… up to n < /p>
compute_odd: 1, 3, 6, 10, 15, 21, 28… до n < /p>
Программа записи, в которой пользователь вводит числа int n1 больше нуля (следовательно, программа побудит пользователя ввести значение, пока условие не будет удовлетворена).
Программа будет печатать на консвет, связанную с n1. /> < /blockquote>
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int n1;
do
{
System.out.println("Enter a positive integer value: ");
n1 = input.nextInt();
} while(n1
Подробнее здесь: https://stackoverflow.com/questions/245 ... mpute-even