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
Which of these purchases is most likely to be paid for with a credit card
Vesna [10]

Answer:

plane ticket?

Explanation:

7 0
3 years ago
Design pseudocode for a program that will permit a user to store exactly 50 numbers in an array. Create an array big enough to h
galben [10]

Answer:

#include<stdio.h>

//declare a named constant

#define MAX 50

int main()

{

   //declare the array

   int a[MAX],i;

   //for loop to access the elements from user

   for(i=0;i<MAX;i++)

   {

      printf("\n Enter a number to a[%d]",i+1);

      scanf("%d",&a[i]);

  }

  //display the input elements

  printf("\n The array elements are :");

  for(i=0;i<=MAX;i++)

  printf(" %d ",a[i]);

}

Explanation:

PSEUDOCODE INPUTARRAY(A[MAX])

REPEAT FOR I EQUALS TO 1 TO MAX

PRINT “Enter a number to A[I]”

READ A[I]

[END OF LOOP]

REPEAT FOR I EQUALS TO 1 TO MAX

PRINT A[I]

[END OF LOOP]

RETURN

ALGORITHM

ALGORITHM PRINTARRAY(A[MAX])

REPEAT FOR I<=1 TO MAX

PRINT “Enter a number”

INPUT A[I]

[END OF LOOP]

REPEAT FOR I<=1 TO MAX

PRINT A[I]

[END OF LOOP]

6 0
3 years ago
Which of the following is not a language commonly used for web programming? PHP Assembly Java Python
Nataly [62]

Answer:

If you’re a software developer, then you probably—every now and then—feel overwhelmed by the super-fast pace at which our industry evolves, and that’s fine. I certainly feel that way sometimes, especially when trying to keep up with the latest trends.

But it’s possible to be well-informed about what’s going on out there, and use that information to your advantage, by being economical about your learning.

Sure, there are lots of programming languages. Sure, new ones keep being created every week—and don’t even get me started on JavaScript frameworks.

Do you need to learn all of them? Of course not.

First, learn about a number of the most popular programming languages. Then, narrow that list down, by picking the ones that make the most sense for your current knowledge level, employment status and other criteria that might make sense for your scenario.

For instance, if you intend to learn the functional paradigm, then pick a functional language from the list. Rinse and repeat.

That’s what this post is about. We’ve done the legwork for you, compiling a list of five of the most popular programming languages for 2019. Now you only have to read it and put it to good use.

(Hope this helped if not i am so so sorry hope you have a blessed day goodbye)

7 0
3 years ago
Read 2 more answers
What command is used to locate all occurrences of the word "dog" in a document?
rosijanka [135]

Microsoft Word can easily find text in your document. This search is handled by the Find command. To locate the occurrences of the word dog in a word document, you can either click the find button on the home tab or press the combination keys ctrl+F and type the word dog. You also press ctrl+G. The Find and Replace dial box will pop up, with the Go To tab displayed. You will go ahead and click the Find tab and type the word dog.

3 0
3 years ago
Read 2 more answers
What is a collection?
Andreyy89
Collections are used to store, retrieve, manipulate, and communicate aggregate data.
7 0
3 years ago
Other questions:
  • Richard needs to copy information from another slide presentation that uses a different design template. To ensure that the info
    7·1 answer
  • What do I need to write ??
    14·1 answer
  • What is the system that consists of nonproprietary hardware and software based on publicly known standards that allow third part
    13·1 answer
  • The physical parts of the computer are known as?
    14·1 answer
  • Pls help I will give lots of points
    9·1 answer
  • Which part of the processing unit does the logic operations?<br> A. ALC<br> B. CU
    9·1 answer
  • Which type of information could be displayed using this line graph?
    12·2 answers
  • When you hear music, read a printout, or view a video, you are using a computer's
    13·1 answer
  • How to install an older version of prettier on yarn
    9·1 answer
  • Will economists be replaced by artificial intelligence?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!