Question: Here is my code: import java.util.*; public class Numbers { public static void main(String [] args) { Scanner scan = new Scanner(System.in); int first, last;
Here is my code:
import java.util.*;
public class Numbers { public static void main(String [] args) { Scanner scan = new Scanner(System.in); int first, last; System.out.print("Starting Number> "); first = scan.nextInt(); System.out.print("Ending Number> "); last = scan.nextInt(); if ((first > last) || (first == last)) { System.out.println("Invalid input "); } else { while(first <= last) { System.out.println(first); first ++; } System.out.println("Done"); } } }
The output should be:
There are 15 numbers between 17 and 31 17 18 19 20 * 21 22 23 24 25 * 26 27 28 29 30 * 31 Done
So there should be an * (asterisk) next to each 5 multiple number. How do I get that?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
