Solution:
Well, your flow-chart looks good. It’s always better to give it a try to write code. Let’s write a code using the scanner class by following your given flowchart.
import java.util.Scanner;
public class Prompting{
public static void main(String []args){
Scanner in = new Scanner (System.in);
boolean valid = false;
double input = 0;
while(!valid){
System.out.println("Enter a positive value<100 : ");
input = in.nextDouble();
if (input>0 && input<100){
valid = true;
System.out.println("This is a good number");
}
else{
System.out.println("Sorry! Invalid Input");
}
}
}
}
As per your flowchart, I made this program. Here, this program will take input and check it if it matches our requirement. It counts only 0 to 100 positive numbers except all it throws back Sorry Invalid Input.
So, run the program and let me know if you have got any questions in the future regarding this issue. Please reply to this thread.
Thanks.