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
Why is it important to minimize cable clutter in a rack?
V125BC [204]

Answer: Cable clutter is the mess created due to cables of the operating system units in the rack.The reduction in the cable clutter is important because it make the computing environment clear and prevent the blockage in flow of air, reducing the litter in rack environment etc  

The clearance of the cable clutter can be done with the help of cable managers for collecting the cables and tying them into one section, organizing and clearing the cabinets of rack.

8 0
2 years ago
Handhed computer is otherwise called as<br> 1.laptop<br> 2.Notebook<br> 3.Palmtop
NikAS [45]

Answer:

personal digital assistants (PDAs)palmtop

3 0
3 years ago
Are you concerned that strangers may have access to the personal information you share on social media platforms? Why or why not
GuDViN [60]
It makes me a little uneasy at times, yes, but I know that they cannot find me unless I share way too much.
Hope this helps~!
~{Oh Mrs. Believer}
4 0
3 years ago
Question :
BlackZzzverrR [31]

Answer:

D

Explanation:

Search engine optimization (SEO)

4 0
3 years ago
__________for about 10 minutes in between each repetition session helps you to remember the information better. a. Reading c. Sl
k0ka [10]

the answer is a.) reading

6 0
2 years ago
Read 2 more answers
Other questions:
  • Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the person's age. Complete fat_burn
    10·1 answer
  • Plz tell me a storage device that should be used for this and why
    11·1 answer
  • Which scientific law states that if a light source radiates isotropically, the light intensity falls off the further you get fro
    5·1 answer
  • URLs are directions that browsers follow in order to find specific web page files. What is the first part of the URL that is the
    14·1 answer
  • Go online and research the computer topic
    6·1 answer
  • Declare an array named tax rates of five elements of type double and initialize the elements (starting with the first) to the va
    12·1 answer
  • a(n) ___ loop allows you to cycle through an array without specifying the starting and ending points for the loop
    14·1 answer
  • Urgent ..algorithm and flowchart to check weather a number is odd or even ???​
    8·2 answers
  • A process at Host C receiving two incoming UDP segments from two different hosts will know that they originated from two differe
    14·2 answers
  • How to add links in HTML? ​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!