Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- boolean isNotCorrect = false;
- System.out.println("Данная программа находит произведение P=2*4*6*8..*2*n;");
- int i = 0;
- int n = 0;
- int comp = 1;
- do {
- try {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Введите число n");
- n = scanner.nextInt();
- if ((n<1) || (n>9)) {
- isNotCorrect = true;
- }
- } catch (Exception e) {
- System.out.println("Введите чило n>5");
- isNotCorrect = true;
- }
- } while (isNotCorrect);
- for (i = 2; i < (2 * n) + 1; i++) {
- if (i % 2 == 0) {
- comp = comp * i;
- }
- }
- System.out.println("Произведение равно " + comp);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement