subject

There is an application which inputs hundred numbers from the user, if user enters a positive number it increments valid numbers count. But if a user enters other than integer it terminates. You are required to make changes in given code such that instead of termination it shows message “input is not valid” and re input a number. importjavax. swing.*;
publicclass QuestionNumber4 {
publicstaticvoidmain(String[] args) {
intcountValidNumber=0;
int num;
for(inti=0;i<100;i++){
System. out. print("Enter a Positive Number:");
String s1 =JOptionPane. showInputDialoge(“enter number”,null);
num = Integer. parseInt(s1);
if(num>0){
countValidNumber++;
}
}
System. out. println("Valid Numbers Are:"+countValidNumber);
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 20:00
2.)how does a graphical user interface (gui) on a touchscreen interface differ from a gui on a desktop or laptop? a.)a finger or stylus is used instead of a pointer. b.) a magic wand is used instead of a pointer. c.)users speak commands instead of using a pointer. d.)users visualize commands instead of using a pointer.
Answers: 1
question
Computers and Technology, 22.06.2019 10:30
Choose the best explanation for the following statement communication is symbolic
Answers: 3
question
Computers and Technology, 22.06.2019 11:00
The great length of north america causes the climate to be varied. true false
Answers: 2
question
Computers and Technology, 22.06.2019 12:30
What characteristic of long period comets suggest they come directly from the oort cloud?
Answers: 2
You know the right answer?
There is an application which inputs hundred numbers from the user, if user enters a positive number...
Questions
question
Health, 12.04.2021 18:40
question
English, 12.04.2021 18:40
question
Mathematics, 12.04.2021 18:40
question
Chemistry, 12.04.2021 18:40