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
Alice is working on a web page to attract the maximum number of people to join her cause. She wants to inform people about the b
Deffense [45]

Answer:

Option D.    Persuasive writing style

is correct answer.

Explanation:

  • Alice should adopt the persuasive writing style as she wants to convince the people to adopt eco-friendly methods of living.
  • When a person write persuasively, this means he/she will present justifications and reasons for that specific opinion he/she is trying to convince the audience.
  • For the correctness of their opinion, different kinds of evidences are prepared so that the fact persuade the reader.
  • Persuasive writing is used widely while writing academic papers, advertisements  and argumentative essays as well.
<h2></h2><h2>i hope it will help you!</h2>

7 0
3 years ago
_____________ describes the abstraction of web-based computers, resources, and services that system developers can utilize to im
Vika [28.1K]

Answer:

c. Cloud computing

Explanation:

Cloud computing -

It refers to the on - time need of the computer resource , in order to store data , computing power by the user , is referred to as cloud computing.

It refers to the availability of the data centers to the user .

This method enables the sharing of resources .

Hence, from the information of the question,

The correct option is c. Cloud computing .

6 0
3 years ago
which of the following peripheral does not belong to a group: A) Monitor B) Printer C) Hardware D) Keyboard​
nikdorinn [45]
C hardware is the correct answer
5 0
3 years ago
What is the benefit of using pre-programmed functions to analyze data?"
Murrr4er [49]

Answer:

A pre-programmed function is a section of code which is reusable to perform certain routine. One benefit of using a pre-programmed function to analyze data is the code redundancy can be reduced. The function is only written for once and it can be called to perform a specific data analysis whenever it is needed.

Besides, a pre-programmed function also offer consistent analytical output as all data are processed by a same analytical procedure in the function.  

5 0
2 years ago
Which of the following identifies the patterns used for each data series in a chart?
Lady_Fox [76]
The answer is A)Legend.
7 0
3 years ago
Other questions:
  • PLS HELP ASAP! WILL GIVE BRAINLIEST!
    14·1 answer
  • I don’t know technically
    9·2 answers
  • Is there a way to find the answers to I ready on the internet?
    6·1 answer
  • What device provides ports to allow a laptop to easily connect to a full-sized monitor, keyboard, ac power adapter, and other pe
    11·1 answer
  • NoSQL is a programming language used to create mobile apps.<br> a) True<br> b) False
    13·2 answers
  • A device that make it possible for a muitiple customer to share one address is called
    13·1 answer
  • 1. provide at least 3 properties and 3 methods of the object computer.
    8·1 answer
  • Where ....................... the books that you borrowed? *
    5·1 answer
  • To what extent do you agree with the assertion that “Collection development begins with community analysis”. (Give reasons to bu
    7·1 answer
  • What is System Testing
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!