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
Naddik [55]
3 years ago
14

Given a scanner reference variable named input that has been associated with an input source consisting of a sequence of integer

s and an int variable named total, write the code necessary to add all the integers in the input source and place their sum into total.
Computers and Technology
2 answers:
DedPeter [7]3 years ago
7 0
The answer is total = 0;while(input.hasNextInt()){total += input.nextInt( );}   Given a scanner reference variable named input that has been associated with an input source consisting of a sequence of integers and an int variable named total, The code necessary to add all the integers in the input source and place their sum into total is :                                                  total = 0;while(input.hasNextInt()){total += input.nextInt( );}   
liq [111]3 years ago
7 0

Answer:

Following are the code written in the Java Programming Language.

total = 0;   //set integer type variable and initialize to 0

while(input.hasNextInt()){   //set the while loop

total += input.nextInt( );  //code is here

}

Explanation:

Here, in the following code create the reference scanner class object i.e., "input".

  • Then, we set integer data type variable "total" and initialize 0 in it.
  • then, we set the while loop and pass the following condition "input.hasNextInt()".
  • Then, we add all integer values and store their sum in the variable "total".
You might be interested in
Write a public static method named evens that takes in 1 argument int a, and returns a String containing all positive even numbe
topjm [15]

public class JavaApplication48 {

   public static String evens(int a){

       String txt = "";

       if (a < 0){

           return "NONE!";

       }

       else if(a%2 == 1){

           a -= 1;

       }

       for (int i = 0; i <= a; i+=2){

           if (i < a){

               txt += i+",";

                       }

           else{

               txt += i;

           }

       }

       return txt;

   }

   public static void main(String[] args) {

       System.out.println(evens(1));

   }

   

}

I hope this helps!

4 0
3 years ago
HURRY
Irina-Kira [14]

<em>Your answer is B: cooperative player-to-player interaction</em>

<em></em>

<em></em>

<em />

6 0
3 years ago
When using the wait and signal operations, ____ sets the process's process control block to the blocked state and links it to th
lbvjy [14]
<span>When using the wait and signal operations, Wait sets the process's process control block to the blocked state and links it to the queue of processes waiting to enter this particular critical region.</span>
3 0
3 years ago
To have different formatting for odd and even rows, select the _____ option.
Ratling [72]
<span>To have different formatting for odd and even rows, 
The option is </span><span>First Column</span>
4 0
3 years ago
What are the missing whole numbers on this number line? Enter your answers in the boxes. plz show work I'm I need answer 3rd gra
adell [148]
1 3 and 4... you are just counting up from 0
5 0
3 years ago
Other questions:
  • Esther has acquired an associate's degree in information technology and certifications in PageMaker and Illustrator. Which caree
    8·2 answers
  • Write the definition of a function half , which receives an integer parameter and returns an integer that is half the value of t
    7·1 answer
  • Jennifer frequently uses a few programs on her laptop. Where will she find all the frequently used program icons in her computer
    13·1 answer
  • Given a one dimensional array arr, what is the correct way ofgetting the number of elements in arr
    15·1 answer
  • After trying multiple times, a coworker is not able to fit a motherboard in a computer case, and is having difficulty aligning s
    11·1 answer
  • A ____ typically rests on the desk or other flat surface close to the user’s computer, and it is moved across the surface with
    13·1 answer
  • Communication media that use an antenna for transmitting data through air or water are called _____.
    14·1 answer
  • To have a reason or purpose to do something
    8·2 answers
  • Which of the following tools helps ensure your document will open in older versions of word
    13·1 answer
  • Which of the following digital communicatio media does not require a connection to the internet
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!