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
Create a program that contains 4 methods / functions... main(), getTestScores(), calcAverage(), and displayAverage(). The main()
jeyben [28]

Answer:

import java.util.Scanner;

public class  num6{

   static int getTestScores(){

       System.out.println("Enter the Score");

       Scanner in = new Scanner(System.in);

       int score = in.nextInt();

       return score;

   }

   static double calcAverage(int score1, int score2, int score3){

       return (score1+score2+score3)/3;

   }

   static void displayAverage(double ave){

       System.out.println("The Average is "+ave);

   }

   public static void main(String[] args) {

       int num1 = getTestScores();

       int num2 = getTestScores();

       int num3 = getTestScores();

       //Calling Calculate Average

       double average = calcAverage(num1,num2,num3);

       //Calling displayAverage

       displayAverage(average);

   }

}

Explanation:

  • Using Java programming Language
  • Create the four methods
  • getTestScores() Uses the Scanner Class to receive an in variable and return it
  • calcAverage() accepts three ints as parameter calculates their average and return it
  • displayAverage() Accepts a double and prints it out with a concatenated string as message
  • In the Main Method, getTestScores is called three times to obtain three numbers from the user
  • calAverage is called and handed the three numbers
  • printAverage is called to output the calculated average
8 0
2 years ago
What does a "swivel chair" work task involve?
nadezda [96]

Answer:

An employee literally swings from application to application to accomplish the laborious task of manually copying information from one application, validating it, and pasting it in another application. In applying human judgment and decision making: Entering data multiple times into different applications. Ensure that complex information obtained from an application is accurate. Communicate physicallly with a group of people simultaneously.

Explanation:

4 0
2 years ago
Assume that name is a variable of type String that has been assigned a value.Write an expression whose value is a String contain
zhuklara [117]

Answer:

#read value of name

name=input("Enter name:")

#find and ptint the last character of the string

print("last character of string is:",name[-1])

Explanation:

Read a string from user and assign it to variable "name".Find its last character as "name[-1]". Since name is character array,so name[-1] will give the last character of the array.

Output:

Enter name:Smith                                                                                                          

last character of string is: h

6 0
3 years ago
Being the Sales Manager of a company you have to hire more salesperson for the company to expand the sales territory. Kindly sug
andrezito [222]

Answer:

1. Identification of a vacancy and development of the job description.

2. Recruitment planning

3. Advertising

4. Assessment and Interview of applicants

5. Selection and Appointment of candidates

6. Onboarding

Explanation:

The Recruitment process refers to all the stages in the planning, assessment, and absorption of candidates in an organization. The stages involved include;

1. Identification of a vacancy and development of the job description: This is the stage where an obvious need in the organization is identified and the duties of the job requirement are stipulated.

2. Recruitment planning: This is the stage where the HR team comes together to discuss the specific ways they can attract qualified candidates for the job.

3. Advertising: The HR team at this point seeks out job sites, newspapers, and other platforms that will make the opportunities accessible to applicants.

4. Assessment and Interview of applicants: Assessments are conducted to gauge the candidates' knowledge and thinking abilities. This will provide insight into their suitability for the job.

5. Selection and Appointment of candidates: Successful candidates are appointed to their respective positions. A letter of appointment is given.

6. Onboarding: Candidates are trained and guided as to the best ways of discharging their duties.

6 0
3 years ago
A man travel 200m towards east<br />from his house then takes left<br />to turn and moves 200 m north<br />fin
11Alexandr11 [23.1K]
Using the Pythagorean theorem:

200^2 + 200^2 = x^2

x = 282.842712... from the original distance
4 0
3 years ago
Other questions:
  • Sniffing network and wireless traffic, intercepting bluetooth traffic, and even using equipment to remotely pull information fro
    12·1 answer
  • In a database, __________ is used to uniquely identify each record for retrieval or manipulation. answer an attribute or a field
    7·1 answer
  • Decision making at the executive or strategic level requires business intelligence and knowledge to support the uncertainty and
    12·1 answer
  • The breastbone or ________________ extends down the chest.
    5·1 answer
  • If we want to access files located in a directory on a remote server, which of these options would we use?
    9·2 answers
  • In java
    6·1 answer
  • Strengths and weaknesses about esport
    10·1 answer
  • Which view would you need to use to make changes to the design theme for the entire presentation?
    10·2 answers
  • ¿Es lo mismo hablar de tecnología que de computadora?
    12·1 answer
  • Which graphic file format would you choose if you needed to make an animated graphic for a website?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!