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
Which of the following protocols is used by Web servers to establish communication between a web page and a web browser?
Iteru [2.4K]
HTTP or HTTPS is most likely the answer you are looking for.
6 0
3 years ago
Divide the difference of 47 and 23 by the difference of 25 &amp;13​
OleMash [197]

Answer:

The answer is 2

Explanation:

3 0
3 years ago
What is input process<br>​
riadik2000 [5.3K]

Answer:

describing the structure of an information processing program or another process. Many introductory programming and systems analysis texts introduce this as the most basic structure for describing a process.

Explanation:

  • A requirement from the environment (input)
  • A computation based on the requirement (process)
  • A provision for the environment (output)

Example: A small engineering firm believes there are problems with its hiring process. Several of the junior engineers that have been hired remained at the firm for less than one year. This is a considerable cost to the firm, since recruiting and training new engineers is time consuming and expensive. The human resources manager decides to put together a group of people with extensive experience hiring new engineers. One of their first tasks is to produce an input-output model of the hiring process. They generate the following.

4 0
3 years ago
_______ is the remote performance of medical exams, consultations, health monitoring and analysis using special medical equipmen
laila [671]

Answer:

eHealth.

Explanation:

eHealth or electronic health is a digital medical platform used to connect individuals to medical treatment they so need but can not receive due to certain barriers.

The eHealth platform uses modern day technology for consultation, examination of patient's health, prescription of medication etc. But it refers patients to trusted medical facilities when the situation is critical.

All these are done electronically through the internet and has eliminated the boundaries of geographical location.

8 0
3 years ago
In Microsoft Word, a user can find the Customize Keyboard dialog box in the Customize Ribbon section of the
MissTica

Answer:

view tab

Explanation:

I think that is the answer

5 0
3 years ago
Other questions:
  • A file that contains program code is called a ____________.
    13·1 answer
  • _____________ is the characteristic of a resource that ensures that access is restricted to only permitted users, applications,
    14·1 answer
  • If a piece of software designed to run on Windows XP can run on the latest version of Windows, we say the latest version of Wind
    14·1 answer
  • In Vista and Windows 7, the Appearance and Personalization option allows you to change the
    14·1 answer
  • When an organization uses cloud computing, they do not have to buy and maintain expensive hardware. Group of answer choices True
    6·1 answer
  • How do you think advances in processors affect corporations that discover the computers they purchased just a couple of years ag
    10·1 answer
  • When you go to a website, your web browser requests a web page from:
    11·1 answer
  • What colorful format should you use to bring attention to an important sentence or phrase
    14·1 answer
  • what is cicada 3301? i will give brainliest if you give me a correct answer (not copy and pasted) and somewhat well detailed, i
    8·1 answer
  • Blockquote
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!