Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Test {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- while(true){
- System.out.print("Enter first number >>>");
- int x = sc.nextInt();
- System.out.print("Enter last number >>>");
- int y= sc.nextInt();
- if ( x == 0 && y == 0 )
- break;
- if( x < y) {
- System.out.println("First number > Last number ");
- }
- else if (x > y) {
- System.out.println("First number > Last number == Error ");
- }
- System.out.println("press 1 for 3 or 5");
- System.out.println("press 2 for 5 or 7");
- int pick = sc.nextInt();
- if(pick == 1){
- for(int i=x ; i <= y ;i++){
- if( i%3 == 0 || i%5 == 0){
- System.out.print(i+" ");
- }
- }
- }
- else if(pick == 2){
- for(int i=x ; i <= y ;i++){
- if( i%5 == 0 || i%7 == 0){
- System.out.print(i+" ");
- }
- }
- }
- else {
- System.out.println("No have choice (1 or 2)");
- }
- System.out.println("");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment