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
What does error code 18 indicate?
RSB [31]

Answer:

you need to reinstall the drivers for the device

7 0
3 years ago
In Word you can _____ or merge two different copies of the same document into one document. a. replicate b. duplicate c. copy d.
defon
D) combine
combine and merge are synonyms of each other.
hope this helps x
6 0
3 years ago
How do you use the Internet? Think about your typical day. When are you using the Internet? For what purposes? What role does it
Basile [38]

Answer:

I use the internet for a variety of activities. In a typical day, I'd use the internet to do the following:

  1. I check my email
  2. follow the latest trends and news on popular social media channels
  3. communicate with friends, family and clients via social media channels
  4. I research business topics
  5. I use it for my work as a management consultant

The internet is now a primary utility. I currently spend more on internet data subscription than on fuel, electricity, phone call credit, and even water. It now has a tremendous impact on my daily life.

Cheers

5 0
3 years ago
Text, numbers,graphics, sounds entered into a computer's memory during input operations are referred to as
Svet_ta [14]
Data, it can only be data.
5 0
3 years ago
Who made computer ? Which year?
myrzilka [38]

Answer:

The first computer that resembled the modern machines we see today was invented by Charles Babbage between 1833 and 1871.

8 0
3 years ago
Read 2 more answers
Other questions:
  • B. Find Addition of Binary Numbers: 1100112 + 11012
    11·1 answer
  • Web-based e-mail like Hotmail is an example of three-tier client-server architecture that provides access to e-mail messages. Tr
    7·1 answer
  • Complete the statement below with the correct term.
    12·2 answers
  • How do you recognize the brand name of a drug in the package insert?
    15·1 answer
  • Write a C function which mimics the behavior of the assembly language function below. Note that this time, the assembly language
    10·1 answer
  • What do you use the Pygame library for?
    6·1 answer
  • Write a program that reads an integer, a list of words, and a character. The integer signifies how many words are in the list. T
    6·1 answer
  • MyProgramming Lab
    5·1 answer
  • Mohammed’s parents learn that his classmates have begun sending him text messages making fun of his heritage. Mohammed says he’s
    5·2 answers
  • If you need to change the typeface of a document, which menu will you choose?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!