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]
4 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]4 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
How has the Aswan High Dem had an adverse effect on human health?​
Lorico [155]

Answer:

How was the Aswan high dam had an adverse effect on human health? It created new ecosystems in which diseases such as malaria flourished. An environmental challenge facing the Great Man Made River is that pumping water near the coast. ... Water scarcity makes it impossible to grow enough food for the population.

Explanation:

7 0
3 years ago
The ability to present an effective message with useful content is obviously important to a good _____ presentation.
Zina [86]

A successful oral presentation depends on your ability to communicate your ideas clearly and with relevant content.

<h3>What is an oral expression? </h3>
  • Oral presentations, often known as public speaking or just presentations, involve one or more speakers discussing a particular topic with an audience.
  • This seeks to provide information, amuse, educate, and/or make a point.
  • When the author speaks in front of other students, coworkers, or other interested groups to convey the results of years of expertise and research while outlining essential elements to success, the book is referred to as an example of oral presentation.
  • An oral presentation is one of the best venues for fusing verbal prowess with powerful nonverbal indicators to extend your communication.
  • It enables people to speak in front of a live audience with assurance about their thoughts and opinions.

To learn more about Oral presentation, refer to:

brainly.com/question/27326303

#SPJ4

7 0
2 years ago
How have computers changed overtime
sattari [20]
So in the beginning, a regular computer took up the space of an entire room it was literally that big in size. now and days computers are this small object that you can carry around with you in your bag.
4 0
3 years ago
Read 2 more answers
Ethernet is a standard for a) LAN b) MAN c) WAN d) All of the above
kotykmax [81]

Answer:

a) LAN

Explanation:

Ethernet is a standard for a IEEE or LAN.

7 0
3 years ago
Read 2 more answers
Which part of the water cycle is most affected by a sunny day with few clouds?
nirvana33 [79]
Increase in evaporation
8 0
3 years ago
Read 2 more answers
Other questions:
  • 2.7 code practice question 1 edhesive
    13·2 answers
  • 3.
    5·1 answer
  • _____ involves storing data and running applications outside the company’s firewall. answer grid computing parallel computing cl
    11·1 answer
  • How to check if serial interface is dte ot DCE?
    13·1 answer
  • Tightly.
    5·1 answer
  • Which of the following options is not located in the page setup dialog box?
    14·1 answer
  • I found a brand-new charger wire still in its plastic package, but it's six years old and has never been used. Is it safe to use
    9·1 answer
  • If the middle number is lesser than the candidates then u eliminate the ___ half of the data​
    5·1 answer
  • Which two statements describe benefits of a block-based coding language
    11·2 answers
  • How do i copy a canvas course from old class to new course.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!