Computers and Technology
Computers and Technology, 27.06.2020 09:01, tonya3498

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);
}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:30, Akkenson17871
The "instance" relationship shows that something is an object of a
Answers: 1
image
Computers and Technology, 22.06.2019 23:00, brooklynmikestovgphx
Suppose s, t, and w are strings that have already been created inside main. write a statement or statements, to be added to main, that will determine if the lengths of the three strings are in order by length, smallest to largest. that is, your code should determine if s is strictly shorter than t, and if t is strictly shorter than w. if these conditions hold your code should print (the boolean value) true. if not, your code should print false. (strictly means: no ties) example: if s, t, and w are "cat", "hats", and "skies" your code should print true - their lengths are 3-4-5; but if s, t, and w are "cats" "shirt", and "trust", then print false - their lengths are 4-5-5 enter your code in the box below
Answers: 2
image
Computers and Technology, 23.06.2019 02:30, jaueuxsn
Which component acts as a platform on which application software runs
Answers: 2
image
Computers and Technology, 23.06.2019 21:40, jeovontamarley
language consists of basic components, and they are called a. 3; mental images, concepts, and speech b. 2; language acquisition and linguistic relativity c. 3; heuristics, algorithms, and analogies d. 4; phonemes, morphemes, syntax, and semantics e. 2; words and grammar
Answers: 3
Do you know the correct answer?
There is an application which inputs hundred numbers from the user, if user enters a positive number...

Questions in other subjects: