Answer to Question #253661 in Java | JSP | JSF for leo

Question #253661

Using a do-while loop create a program that will prompt the user for a number and then print out a list 5 odd numbers above the given number(inclusive).



1
Expert's answer
2021-10-19T15:19:29-0400
import java.util.Scanner;


public class App {
	/**
	 * The start point of the program
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);// create Scanner object 
		int number=0;
		System.out.print("Enter a number: ");
		number = input.nextInt();
		int counter=0;
		System.out.println("A list 5 odd numbers above the given number: ");
		do {
			if(number%2==1) {
				System.out.println(number);
				counter++; 	
			}
			number++;
		}while(counter<5);
		
		input.close();


	}


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS