پاسخ ها ( ۳ )

  1. باسلام

    import java.util.Scanner;
    public class MainClass {

    public static void main(String[] args) {

    System.out.print(“inter first number :”);
    Scanner reader = new Scanner(System.in);
    int a = reader.nextInt() ;
    System.out.print(“inter secand number :”);
    int b = reader.nextInt();

    if (a % 2 == 0) {
    System.out.println(a);
    }
    if ( b % 2 == 0 ) {
    System.out.println(b);
    }

    if (a % 2 != 0 && b % 2 != 0 ){
    System.out.println(” there’s not any even number “);
    }
    }

    }

  2. System.out.print(“inter first Number:”);
    Scanner reader=new Scanner(System.in);

    int a= reader.nextInt();
    System.out.print(“inter last Number:”);

    int b= reader.nextInt();

    if (a%2==0) {

    for (int i = a; i <=b; i+=2) {
    System.out.print(i+”,”);
    }
    }
    else if (a%2==1) {
    a++;
    for (int i = a; i <=b; i+=2) {
    System.out.print(i+”,”);
    }
    }

ارسال یک پاسخ