1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anton [14]
3 years ago
6

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 0){ countValidNumber++; } } System.out.println("Valid Numbers Are:"+countValidNumber); }
Computers and Technology
1 answer:
Sveta_85 [38]3 years ago
6 0

Answer:

Following are the correct code to this question:

import java.util.*;//import package

public class QuestionNumber4 //defining class  QuestionNumber4

{

   public static void main(String[] args)//defining the main method

   {

       int countValidNumber=0,n=0;//defining integer varaible

       int num[]= new int[100]; //defining integer array num

       Scanner ob=new Scanner(System.in);//creating Scanner class Object

       try //using try block

       {

       for(int i=0;i<100;i++)//defining loop to input 100 values

       {num[i]=ob.nextInt();//input value in array

        n=n+num[i];//add number

        countValidNumber++;//count input value

       if(n<0){}}//defining if block to check another value

       }

       catch(Exception e) //catch block to handle Exception

       {

       System.out.println("input is not valid");// print message    

       }

   System.out.println("total intered number are: " + countValidNumber);//print times of input value  

   }  

}

Output:

2

5

7

9

o

input is not valid

total intered nyumber are: 4

Explanation:

following are the description of the above code:

  • In the above program code, a class "QuestionNumber4" is declared, inside the class main function is declared, in this method two integer variable "countValidNumber, n" and an integer array "num" is declared.
  • In the next step, the scanner class object is created to input the value from the user and passed into the try-catch block.
  • In the try block, we input values with the help of loop and in the catch block, we handle there exception and at the last, we print times of input, when user input numbers.  
You might be interested in
A python package used in text analysis and natural language processing. True or False
allsm [11]

Answer:

"True" is the correct answer for the above question.

Explanation:

  • There are so many python package which is used in NLP and text analysis.
  • The NLP is a concept in which the system is being interact with the human language and able to understand the human language. This provide the system which is used to intract the computers and humans.
  • The library which is used in NLP are The Conqueror: NLTK, The Prince: TextBlob.
  • The above question also states that there is a library, so it is true statement.
5 0
2 years ago
How do mark somebody as brainliest??
svet-max [94.6K]

Answer:

Once more that one person answer, you will get an option next to the heart and the star that would look like a crown

Explanation:

That is how you do it.

4 0
2 years ago
How many basic elements of QBASIC are there
Masteriza [31]
<h2>6</h2>

The elements used in Qbasic:

  • Character set.
  • Variables.
  • Constants.
  • Operator and Operands.
  • Expression.
  • Statements.
6 0
2 years ago
Quality answers will be appriciated! :)​
Naddika [18.5K]
<h2>1.</h2>

  1. F
  2. T
  3. T
  4. T
  5. F
  6. F
  7. T

________

<h2>2.</h2>

  1. A
  2. B
  3. D5*E5
  4. A

6 0
2 years ago
Read 2 more answers
________ programs help solve the problem of running out of storage space by providing lists of application programs, stored vide
Leviafan [203]

Answer:

Storage management

Explanation:

The programs that do this are known as Storage management programs. They are incredibly useful since they allow you to see which files are taking up the most amount of space as well as the importance that each file has on the system. Many of these programs have a different visual representation of the files such as pie charts or system blocks showing the percentage of space it is taking up. Everything in these programs is made to help the end-user visualize and analyze their data thoroughly.

7 0
3 years ago
Other questions:
  • The main activity area or the brain of the computer is called the ________
    15·1 answer
  • Upon looking out at the
    8·2 answers
  • We will pass in a value N. Write a program that outputs the complete Fibonacci sequence for N iterations. Important: If N is 0,
    13·1 answer
  • Match the installation type to its description.
    9·1 answer
  • 1. Build and test D-type Flip-Flop using a built-in SR flip-flop.
    12·1 answer
  • lance has three tables in his database. He wants to generate a report to show data from the three tables. Therefore, he decides
    7·2 answers
  • To all paladins players out there!!!!!
    14·1 answer
  • How do operating system work?
    5·1 answer
  • What is problem scoping
    14·1 answer
  • Retype the below code. Fix the indentation as necessary to make the program work.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!