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
Maurinko [17]
3 years ago
9

6.16 LAB: Find largest number (EO) Write a method, findMax(), that repeatedly reads in integers until a negative integer is read

and keeps track of the largest integer that has been read. findMax() then returns the largest number entered. Ex: If the input is: 2 77 17 4 -1 the findMax() returns and the program output is: 77 Assume a user will enter at least one non-zero integer. Note: Your program must define the method: public int findMax()
Computers and Technology
1 answer:
Zolol [24]3 years ago
7 0

Answer:

Explanation:

The following code is written in Java, it creates and tests the findMax() method with the test inputs provided in the question. The method loops through asking the user for inputs, if a positive number is passed it checks if it is larger than the previous numbers and if so, saves it in a variable called max. Otherwise it breaks the loop and returns the variable max. The test output can be seen in the attached picture below.

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       System.out.println("Max number is: " + findMax());

   }

   public static int findMax() {

       int max = 0;

       Scanner in = new Scanner(System.in);

       while (true) {

           System.out.println("Enter a number: ");

           int num = in.nextInt();

           if (num >= 0) {

               if (num > max) {

                   max = num;

               }

           } else {

               break;

           }

       }

       return max;

   }

}

You might be interested in
Can someone tell me how to get rid of the the orange with blue and orange on the status bar
igor_vitrenko [27]

Answer:

Explanation:

i'm not sure how tho

5 0
3 years ago
Read 2 more answers
A ________ is an application program that runs on a server-tier computer and manages processes such as items in a shopping cart
garik1379 [7]
Commerce Server

An application program that runs on a server tier computer. A typical commerce server obtains product data from a database, manages items in users' shopping carts, and coordinates the checkout process.
6 0
2 years ago
PLSSSSS HELPP!! Population biologists are concerned about invasive species such as the zebra mussel found in North American wate
elixir [45]

Answer: A.The introduced species compete for resources more effectively than native species.

Explanation:

An introduced species is also called the exotic species and this is an organism which is not a native organism or specie and therefore isn't native to the place but rather it's being transported to the place through the activities of human being.

When the introduced species are introduced to a particular area, they compete with the natives for the available resources and often do this more effectively than the other native species.

Therefore, the correct option is A.

4 0
3 years ago
Which command group on the Slide Master tab is used to add headers, footers, and other placeholders to the slide
Vikki [24]

Answer:D

Explanation:

7 0
2 years ago
Read 2 more answers
1. Given two numbers, n and k ( 0< n, k <=12), generate all the pemutations taking k letters from n letters (nPk) consider
mixer [17]
It is 5jsjsjdhhdhdhdhdhdhdhdhdhd
8 0
3 years ago
Other questions:
  • Suppose two computers (A & B) are directly connected through Ethernet cable. A is sending data to B, Sketch the waveform pro
    9·1 answer
  • WHOEVER HELPS ASAP GETS BRAINLiEST!!!!!!!!! :)
    15·2 answers
  • Give two reasons why it is important to upgrade your browser when a new version becomes available.
    8·1 answer
  • Which of the following is NOT a Boolean Search term used to refine search engine results? A. AND B. With C. OR D. NOT
    14·2 answers
  • Which property is assigned to a file by the operating system?
    13·1 answer
  • What is the result when you run the following line of code after a prompt??
    5·1 answer
  • The sun can be an excellent source of natural light.<br> True.<br> False.
    8·2 answers
  • Which key doesn't relate to keyboard A:return key B :enrollment key C: delete key D:tab key
    9·2 answers
  • What are your strongest competencies? What will you do them? <br>❌NONSENSE ANSWER<br>​
    9·1 answer
  • There are a wide variety of nonsampling errors that can occur during data collection including the first type, ________.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!