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
Importance of project risk management
kkurt [141]
You must spread your risks out like don’t put all your eggs in one basket... don’t rely on on thing because is it goes downhill you have no backup
5 0
4 years ago
An assembly line is an example of which of the following facility layouts?
ikadub [295]

Answer:

Product layout

Explanation:

In configuration of facilities, the four layouts used are the process, product, cellular and fixed-position layouts.In process layout, operations that have similar functions are placed together. Example is a machine shop in manufacturing scenario.Product layouts are applied where there is repetitive assembly and processes.For example in flow shops where large volume of products are produced in a short time. Products that are very large or too heavy use fixed position layouts.Example is ship building or dam construction which require on-spot job performing.Cellular layouts is an equipment layout that will ease the process of cellular manufacturing.For example in group technology, parts of similar designed are identified to be grouped with processes that have similar characteristics to avoid re-arranging of layouts.

6 0
3 years ago
Many programming languages require a ____ to create executable files.
Nadya [2.5K]
Most languages require a compiler. This is because machine code consists of only 0s and 1s, which is executable. All other languages have to be translated into machine language by a compiler.
4 0
4 years ago
If a priority queue is being implemented using an unordered list, what is the Big-O complexity of the Enqueue operation?
lidiya [134]

Answer:

<u>the answer is O(1)</u>

Explanation:

A priority queue is a type of queue whereby each of the elements are linked with a priority and the elements are served according to their priority.

The word enqueue means to add elements to the back of the queue

<em><u>For this question, while using an unordered list, O(1) is the big-O complexity of the enqueue operation. O(1) is a natural Choice for queues.</u></em>

6 0
3 years ago
Assume that the "read/write file to hard disk" library is part of the kernel. Assume that this library uses 1MB of RAM. Assume t
scZoUnD [109]

Answer:

The Answer is 1 MB.

Explanation:

In order to replace the library it must write 0 MB to hard drive then only it can be replaced. Therefore 1 MB is the correct answer.

5 0
4 years ago
Other questions:
  • To avoid potential documentary errors and security leaks, the configuration of firewalls should not be documented unless strictl
    5·1 answer
  • A fitness tracker can be classified as a wearable computer. true
    9·1 answer
  • Data means a group of numbers. <br> a. True<br> b. False
    7·1 answer
  • An attacker compromises the Washington Post's web server and proceeds to modify the homepage slightly by inserting a 1x1 pixel i
    12·1 answer
  • Your company leases a very fast internet connection and pays for it based on usage. You have been asked by the company president
    8·1 answer
  • Given that note, write a program which tells us the major scale starting at that note, using the pattern above. In the main bloc
    6·1 answer
  • What is the location in the base interface of the link to
    7·1 answer
  • State and give reason, if the following variables are valid/invalid:
    12·1 answer
  • A chemical mixture that is burned to produce thrust. (Jet engine homework)
    14·2 answers
  • The following SQL is which type of join? SELECT CUSTOMER_T. CUSTOMER_ID, ORDER_T. CUSTOMER_ID, NAME, ORDER_ID FROM CUSTOMER_T,OR
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!