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
grigory [225]
3 years ago
13

Write a method maxMagnitude() with two integer input parameters that returns the largest magnitude value. Use the method in a pr

ogram that takes two integer inputs, and outputs the largest magnitude value.
Ex: If the inputs are: 5 7 the method returns: 7
Ex: If the inputs are: -8 -2 the method returns: -8
Computers and Technology
1 answer:
yawa3891 [41]3 years ago
3 0

Answer:

The program in Java is as follows:

import java.util.*;

import java.lang.Math;

public class Main{

public static int maxMagnitude(int num1, int num2){

    int mag = num2;

    if(Math.abs(num1) > Math.abs(num2)){

        mag = num1;

    }

    return mag;

}

public static void main(String[] args) {

 int num1, num2;

 Scanner input = new Scanner(System.in);

 System.out.print("Enter two integers: ");

 num1 = input.nextInt();

 num2 = input.nextInt();

 System.out.println(maxMagnitude(num1,num2));

}

}

Explanation:

The method begins here

public static int maxMagnitude(int num1, int num2){

This initializes the highest magnitude to num2

    int mag = num2;

If the magnitude of num1 is greater than that of num2

    if(Math.abs(num1) > Math.abs(num2)){

mag is set to num1

        mag = num1;

    }

This returns mag

    return mag;

}

The main  method begins here

public static void main(String[] args) {

This declares num1 and num2 as integer

 int num1, num2;

 Scanner input = new Scanner(System.in);

This prompts the user for two integers

 System.out.print("Enter two integers: ");

This gets input for the first integer

 num1 = input.nextInt();

This gets input for the second integer

 num2 = input.nextInt();

This calls the maxMagnitude method and prints the number with the highest magnitude

 System.out.println(maxMagnitude(num1,num2));

}

You might be interested in
What makes an App different than others?
Sergio [31]

Answer:

codes

Explanation:

the technique to code different codes matters alot in making your app unique

3 0
3 years ago
Read 2 more answers
Write a function called count_vowels that accepts a string argument that represents a word and returns the number of vowels that
stellarik [79]

Answer:

public static int count_vowels(String str){

       String word = str.replaceAll("[^a-zA-Z0-9]", "");

       String text = word.toUpperCase();

       int lenOfString = text.length();

       int count =0;

       for(int i =0; i<lenOfString; i++){

           if(text.charAt(i)=='A'||text.charAt(i)=='E'||text.charAt(i)=='I'

                   ||text.charAt(i)=='O'||text.charAt(i)=='U'){

               count++;

           }

       }

       return count;

   }

Explanation:

This has been implemented using Java programming language.

Firstly, white spaces, special characters and punctions are removed from the string uisng the replaceAll() method

The string is converted to all upper cases

a for loop is used to count the number of vowels and store to a variable count

In the main method a call to count_vowels is done

<em>public class num1 {</em>

<em>    public static void main(String[] args) {</em>

<em>        String name = "David %$ !. gjak";</em>

<em>        System.out.println("The number of vowels in "+name+ " are "+count_vowels(name));</em>

<em>    }</em>

<em>    public static int count_vowels(String str){</em>

<em>        String word = str.replaceAll("[^a-zA-Z0-9]", "");</em>

<em>        String text = word.toUpperCase();</em>

<em>        int lenOfString = text.length();</em>

<em>        int count =0;</em>

<em>        for(int i =0; i<lenOfString; i++){</em>

<em>            if(text.charAt(i)=='A'||text.charAt(i)=='E'||text.charAt(i)=='I'</em>

<em>                    ||text.charAt(i)=='O'||text.charAt(i)=='U'){</em>

<em>                count++;</em>

<em>            }</em>

<em>        }</em>

<em>        return count;</em>

<em>    }</em>

<em>}</em>

<em />

The complete program with a Main method is given below

3 0
3 years ago
The big data v that defines the fact users expect their data to be accurate and trustworthy is?
dedylja [7]

Veracity is the big data term that describes the reality that people want their data to be reliable and accurate.

<h3>What is big data?</h3>
  • Big data refers to data collections that are too large or complex for software used for traditional data processing to manage. Despite having greater statistical power, data with more fields may also have a higher probability of false discovery than data with fewer fields.
  • Big data is characterized as data that is more diverse, arrives more quickly, and comes in bigger amounts.
  • Another term for this is the three Vs. Big data is just a word for larger, more complicated data collections, particularly from new data sources.
  • One example of the numerous sources of big data is transaction processing systems, customer databases, documents, emails, medical records, internet clickstream logs, mobile apps, and social networks.

To learn more about big data, refer to:

brainly.com/question/19049345

#SPJ4

5 0
2 years ago
Name at least four factors that are looked at when a lender considers whether you are creditworthy.
emmasim [6.3K]
Sepa la verga cx I don't even know this
6 0
3 years ago
The internet may best be compared to a
liraira [26]
I would say a calculator.
7 0
3 years ago
Read 2 more answers
Other questions:
  • What is heat sink?what is its use?If it is not in the system what will happen?
    12·1 answer
  • The search text that you type is called your _____.
    11·1 answer
  • Write an application program that creates and prints a random phone number of the form XXX-XXX-XXXX. Include the dashes in the o
    5·1 answer
  • Which of the following can be used to visually represent information similar to diagrams?
    6·2 answers
  • The bantu and arabic languages blended, creating what new language?
    14·2 answers
  • Sidney works in the accounting department. His boss just assigned him a task that involves creating budget formulas for the comp
    15·1 answer
  • Write a loop to print 10 to 90 inclusive (this means it should include both the
    10·1 answer
  • Cryptocurrencies are digital tokens that are created independently of government money, and can act as a medium of exchange and
    15·1 answer
  • What are all the Answer Streaks (Fun Facts) for brainly?
    13·2 answers
  • Which key doesn't relate to keyboard A:return key B :enrollment key C: delete key D:tab key
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!