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
Explain the relationship between society and the technologies of using Earth's resources?
julsineya [31]
Earth is natural and technology has a thing that can make u sick
5 0
3 years ago
PLS HURRY!! This OS introduced a very cool GUI that had animations and transparencies.
Mumz [18]

Answer:

I think Windows 98 or XP it's one of those

Explanation:

6 0
3 years ago
after installing a secondary hard drive what needs to be done to the hard drive and what do these two task do?
gladu [14]
Keep the first hard drive then override it insert the second one and memory goes into the second one
8 0
3 years ago
_____ means collecting vast amounts of data from a host of websites.
xenn [34]

Answer:

D

Explanation:

D. Web Scraping is the answer

8 0
2 years ago
Read 2 more answers
Lesson 1 (4.0 points)
sesenic [268]


3. Hold down the CTRL, ALT, and DELETE keys simultaneously, click Task Manager option, then right-click the frozen program's name, and finally click the end task button.


8 0
3 years ago
Read 2 more answers
Other questions:
  • convert the following c code to mips. assume the address of base array is associated with $s0, n is associated with $s1, positio
    14·1 answer
  • The main purpose of a constructor is to initialize the data members at the moment that an object is created. true or false?
    8·1 answer
  • "PindCart, an online retailer, places a small file on the computer hard drive of its visitors to recognize them when they revisi
    7·1 answer
  • The stream cipher described in Definition 2.1.1 can easily be generalized to work in alphabets other than the binary one. For ma
    10·1 answer
  • What is boolean rules​
    12·1 answer
  • You can use a minus sign to make a negative numberlike -2. What happens to each of the following 2++2
    8·1 answer
  • What blockchain implementation resulted from bitcoin’s rejection of a recommendation to enhance its scripting language support?
    9·1 answer
  • Ten ways ict has helped in social development
    7·1 answer
  • What makes a recipe for a meal an example of an algorithm?
    6·1 answer
  • What is Frederick Taylor attributed to doing
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!