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
oee [108]
4 years ago
13

Write the definition of a method named add that receives a reference to a Scanner object associated with a stream of input consi

sting of integers only. The method reads all the integers remaining to be read from the stream and returns their sum. So if the input were 3 51 204 17 1040 the returned value would be 1315
The method must not use a loop of any kind (for, while, do-while) to accomplish its job.
Computers and Technology
1 answer:
Lisa [10]4 years ago
5 0

Answer:

import java.util.*;

class Main  

{

   public static void main(String[] args)

   {

       System.out.println("Enter integers and 0 to exit");

       Scanner a1=new Scanner(System.in);

       System.out.println(add(a1));

       

   }

  public static int add(Scanner a1)

  {

        int total = a1.nextInt();

          if (a1.hasNextInt())

              {

                 total =total +add(a1);

              }

       return total;

   }

}

Explanation:

The only thing that needs explanation here is hasnextInt. This returns true if entered number is integer and false if entered is not an integer. And rest is as shown in the program.

You might be interested in
Prehistoric music was often written down on clay tablets
Fudgin [204]

It is false. Just took a quiz with this question. It is 100% FALSE because I put true and got it wrong.

4 0
3 years ago
Jennifer is trying to install an anti-malware program on a computer that she believes might be infected. During the installation
sesenic [268]

Answer:

B. Install in Safe Mode.

Explanation:

Since Jennifer is using the administrator account, she should be able to install the program.

Hence, she should install the anti-malware software in Safe Mode.

In Computer science, Safe Mode is a mode in which the operating system loads only the bare minimum services, process and programs to boot or start up.

Hence, Safe Mode will ensure that when Jennifer is installing the anti-malware software, no other program or service is running which may interfere with her installation.

4 0
4 years ago
Write a C++ program to find K largest elements in a given array of integers. For eeample, if K is 3, then your program should ou
Anon25 [30]

Answer:

// C++ program to find k largest elements in the array

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variable

int n,k;

cout<<"Enter the number of elements of array:";

// read the value of n

cin>>n;

// declare the array of size n

int arr[n];

cout<<"Enter the elements of array:";

// read the elements of array

for(int a=0;a<n;a++)

{

   cin>>arr[a];

}

cout<<"Enter the value of K:";

cin>>k;

// call the function to perform selection Sort

sort(arr, arr+n);

cout << k<<" largest elements of the array are: ";

// print k largest elements of the array

for (int i=n-1; i>n-k-1; i--)

cout << arr[i] << " ";

return 0;

}

Explanation:

Read the number of elements in the array.Then create an array of size "n" and read  n elements of the array.Sort the array in ascending array.Then Read the value of  k from user.Find the k Elements from the end of the array.This will be the k  largest elements of the array.

Output:

Enter the number of elements of array:8                                                                                    

Enter the elements of array:34 8 75 99 12 7 5 55                                                                          

Enter the value of K:3                                                                                                    

3 largest elements of the array are: 99 75 55

4 0
3 years ago
Sara is having a tough time finding the cause of a problem on a computer she is troubleshooting. She found a possible problem bu
sp2606 [1]

<u>I will advise Sara to do research about the problem on the Internet.</u>

<u>Explanation</u>:

Internet is a network that helps in connecting one computer with other globally. Communication between the computers is possible until the computers are connected with to the Internet. Internet helps in getting information from any computer and interacts with the users of the computer.

Sara finds some issue with her computer. She was troubleshooting, but she could not find the exact problem. She was not sure with the problem that she found. It is better for Sara to do research about her problem on Internet and find the solution.

7 0
3 years ago
Kyle, a receptionist for a building supply company, recently won an award for saving his company money on their phone system. Af
Akimi4 [234]
The answer is most likely VoIP which means Voice over Internet Protocol. This is for example skype
8 0
3 years ago
Read 2 more answers
Other questions:
  • Candace opened an email from a person she didn't know and clicked on a pop-up in the email that installed a virus on her compute
    8·2 answers
  • Jasmine took many pictures at a photo shoot. She wants to transfer these pictures from her camera to her laptop for image enhanc
    10·2 answers
  • If you're able to understand directions more easily when you hear them instead of reading them you are most likely
    12·1 answer
  • What argument for "the seen" suggested that breaking windows is a good thing?
    11·1 answer
  • Which characteristic describes the troposphere?
    10·1 answer
  • Which devices are managed through device management? Device management is the process of managing----(blank)-----devices.
    15·1 answer
  • When should students practice netiquette in an online course? Check all that apply.
    9·1 answer
  • Power point is hardware or software​
    12·2 answers
  • Tristan just downloaded a new game he wants to play on his computer. What kind of file should he open in order to install and ru
    5·1 answer
  • Who made the game Monopoly???
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!