Skip to main content
deleted 7 characters in body
Source Link
Kj45
  • 109
  • 1
  • 3
  • 6

Write a program that reads two integers start and end from the user and prints the number from start to end inclusive. However, If end was less than start than you should print them in descending order.

public static void main(String[] args) 
{
    Scanner scan = new Scanner(System.in);
    
    int start = scan.nextInt();
    int end = scan.nextInt();

    if(start < end)
        for(int i = start; i <= end; i++)
            System.out.print(i + " ");
    
    else if(start > end)
        for(int i = start; i >= end; i--)
            System.out.print(i + " ");  
}
}

Write a program that reads two integers start and end from the user and prints the number from start to end inclusive. However, If end was less than start than you should print them in descending order.

public static void main(String[] args) 
{
    Scanner scan = new Scanner(System.in);
    
    int start = scan.nextInt();
    int end = scan.nextInt();

    if(start < end)
        for(int i = start; i <= end; i++)
            System.out.print(i + " ");
    
    else if(start > end)
        for(int i = start; i >= end; i--)
            System.out.print(i + " ");  
}
}

Write a program that reads two integers start and end from the user and prints the number from start to end inclusive. However, If end was less than start than you should print them in descending order.

public static void main(String[] args) 
{
    Scanner scan = new Scanner(System.in);
    
    int start = scan.nextInt();
    int end = scan.nextInt();

    if(start < end)
        for(int i = start; i <= end; i++)
            System.out.print(i + " ");
    
    else if(start > end)
        for(int i = start; i >= end; i--)
            System.out.print(i + " ");  
}
added 12 characters in body
Source Link
Phrancis
  • 20.4k
  • 6
  • 68
  • 154

Write a program that reads two integers start and end from the user and prints the number from start to end inclusive. However, If end was less than start than you should print them in descending order.

Write a program that reads two integers start and end from the user and prints the number from start to end inclusive. However, If end was less than start than you should print them in descending order.

public static void main(String[] args) 
{
    Scanner scan = new Scanner(System.in);
    
    int start = scan.nextInt();
    int end = scan.nextInt();

    if(start < end)
        for(int i = start; i <= end; i++)
            System.out.print(i + " ");
    
    else if(start > end)
        for(int i = start; i >= end; i--)
            System.out.print(i + " ");  
}
}

}

Write a program that reads two integers start and end from the user and prints the number from start to end inclusive. However, If end was less than start than you should print them in descending order.

public static void main(String[] args) 
{
    Scanner scan = new Scanner(System.in);
    
    int start = scan.nextInt();
    int end = scan.nextInt();

    if(start < end)
        for(int i = start; i <= end; i++)
            System.out.print(i + " ");
    
    else if(start > end)
        for(int i = start; i >= end; i--)
            System.out.print(i + " ");  
}

}

Write a program that reads two integers start and end from the user and prints the number from start to end inclusive. However, If end was less than start than you should print them in descending order.

public static void main(String[] args) 
{
    Scanner scan = new Scanner(System.in);
    
    int start = scan.nextInt();
    int end = scan.nextInt();

    if(start < end)
        for(int i = start; i <= end; i++)
            System.out.print(i + " ");
    
    else if(start > end)
        for(int i = start; i >= end; i--)
            System.out.print(i + " ");  
}
}
Source Link
Kj45
  • 109
  • 1
  • 3
  • 6

Two integers start and end

Write a program that reads two integers start and end from the user and prints the number from start to end inclusive. However, If end was less than start than you should print them in descending order.

public static void main(String[] args) 
{
    Scanner scan = new Scanner(System.in);
    
    int start = scan.nextInt();
    int end = scan.nextInt();

    if(start < end)
        for(int i = start; i <= end; i++)
            System.out.print(i + " ");
    
    else if(start > end)
        for(int i = start; i >= end; i--)
            System.out.print(i + " ");  
}

}