- #1
aldofo
- 1
- 0
here is
this code asks the user every time that this program prints a odd number, but I want to print all the odd numbers and them ask the user.
this is what i have to do.
Write a program that asks the user to enter two numbers. The program should display all the odd numbers between the two numbers. The program will ask the user if he wishes to perform the operation again. If so, it should repeat, otherwise it should terminate
Code:
import java.util.*;
public class oddNumbers
{
public static void main(String[] args){
System.out.println("enter two number");
Scanner kb=new Scanner(System .in);
int number=kb.nextInt();
int number2=kb.nextInt();
int s=number2/2;
String decision;
while(number>number2)
{
System.out.println("Error enter input again");
number=kb.nextInt();
number2=kb.nextInt();
s=number2/2;
}
do{
System.out.println(number*2);
number++;
System.out.println("do you want to continue");
ddecisionkb.nextLine();
}while (decisionequals("yes")||decisionquals("Y…
}
}
this code asks the user every time that this program prints a odd number, but I want to print all the odd numbers and them ask the user.
this is what i have to do.
Write a program that asks the user to enter two numbers. The program should display all the odd numbers between the two numbers. The program will ask the user if he wishes to perform the operation again. If so, it should repeat, otherwise it should terminate