Write a method maxMagnitude() with two integer input parameters that returns the largest magnitude value. Use the method in a program 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

Answers

Answer 1

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));

}


Related Questions

3.4 code practice question 2 edhesive

Answers

???????????????????
Is there more to this question??

∉∉∉⊆αβ∞∞the life of me

Answers

Answer:

?

Explanation:

I honestly agree to this statement
So poetic

What symbol next to the records indicates that a table includes a subdatasheet? an asterisk a plus sign a question mark an exclamation point

Answers

Answer:

A plus sign

Explanation:

EDGE 2021

Answer: or in other words B

Explanation: on edg hop this helps

Why are iterators useful?

Select one:
a. Iterators prevent infinite loops
b. Iterators are easier to loop over than a while loop
c. Iterators walk down a collection faster than a for loop.
d. Iterators give you direct access to private variables.
e. Improve information hiding by not revealing how a collection class is implemented

Answers

It is d because I said it is

Which company provides a crowdsourcing platform for corporate research and development?
OA.
MTurk
OB.
WikiAnswers
O C.
MediaWiki
OD.
Innocentive

Answers

Answer:

OA.

MTurk(mechanical turk)

Explanation:

Mechanical Turk is a Microwork service provided by Amazon. Correct answer: C It is an online “crowdsourcing” marketplace that was launched in 2005 by Amazon.

This site (service)   allows businesses and individuals to post short tasks and pay workers to complete them.

Mechanical Turk is a company that provides a crowdsourcing platform for corporate research and development.

What is Mechanical Turk?

Mechanical Turk is a crowdsourcing platform that gather information and makes it possible for individuals and businesses to outsource jobs to people who have the ability to do the task online or virtually. These can include data entry, reasearch, survey participation and so on. to a distributed workforce who can perform these tasks virtually.

Crowdsourcing is a platform that gather information about jobs and service provider online.

Therefore, Mechanical Turk is a company that provides a crowdsourcing platform for corporate research and development.

Learn more of Crowdsourcing from the link below.

https://brainly.com/question/1788104.

what does this mean on a tamagotchi lol (this is the hello kitty one)

Answers

I not sure but I think it’s an apple.

I don't have that tamagotchi

But I do have 2 tamagotchi's

I think it's a cherry on your tamagotchi

Hoped this helped!

Have a wonderful day-

write a complete program for the following situation related to the setting the speed of a car preset values before starting journey. . if speed is less than lower_set_speed, display the message "accelerate" to the screen, increases the cars speed to the lower set speed and output the new speed to screen .if speeds greater than upper_set_ speed, print the message "apply brake" to the new speed to the screen .Give all necessary documentation in the comments, including the file name. .allow the program to exit at the end. .output the speed to the screen. . how many different initial speeds will you need to test this code?

please help me it means a lot​

Answers

Answer:

Explanation:

Please specify which programming language this is supposed to be written in.

Without knowing that, only the last part can be answered "how many different initial speeds will you need to test this code?"

You will need to test at least 3 initial speeds: one below the lower-set-speed, one between the lower- and upper-set-speed and last one which is above the upper-set-speed.

When dragging a sheet tab to move it, the location of the _______ determines where the sheet tab will be moved.

square
line
arrow
last tab

Answers

the location of the arrow determines it

Create an application containing an array that stores eight integers. The application should call five methods that in turn:
Display all the integers
Display all the integers in reverse order
Display the sum of the integers
Display all values less than a limiting argument
Display all values that are higher than the calculated average value.
public class ArrayMethodDemo {
public static void main (String args[]) {
int[] numbers = {12, 15, 34, 67, 4, 9, 10, 7};
int limit = 12;
display(numbers);
displayReverse(numbers);
displaySum(numbers);
displayLessThan(numbers, limit);
displayHigherThanAverage(numbers);
}
public static void display(int[] numbers) {
// Write your code here
}
public static void displayReverse(int[] numbers) {
// Write your code here
}
public static void displaySum(int[] numbers) {
// Write your code here
}
public static void displayLessThan(int[] numbers, int limit) {
// Write your code here
}
public static void displayHigherThanAverage(int[] numbers) {
// Write your code here
}
}

Answers

Answer:

public class ArrayMethodDemo {

   public static void main (String args[]) {

       int[] numbers = {12, 15, 34, 67, 4, 9, 10, 7};

       int limit = 12;

       display(numbers);

       displayReverse(numbers);

       displaySum(numbers);

       displayLessThan(numbers, limit);

       displayHigherThanAverage(numbers);

   }

   

   public static void display(int[] numbers) {

       

       //Message to be displayed before printing out the numbers

      System.out.print("Numbers in the array: ");

       

       //loop through the numbers in the array and print each number

       for(int x: numbers){

           System.out.print(x + " ");

       }

       

       //print a new line

       System.out.println();

   }

   

   public static void displayReverse(int[] numbers) {

       

       //Message to be displayed before printing out the reverse of the array

       System.out.print("Reverse of the array numbers: ");

       

       

       //loop through the array starting from the last index

       for(int i = numbers.length - 1; i > 0; i--){

           System.out.print(numbers[i] + " ");

       }

       

       //print a new line

       System.out.println();

   }

   

   public static void displaySum(int[] numbers) {

       

       //initialize the sum variable

       int sum = 0;

       

       //loop through the array and add each element to sum

       for(int i = 0; i < numbers.length; i++){

           sum += numbers[i];

       }

       

       //print out the sum

      System.out.println("Sum: "  + sum);

       

   }

   

   public static void displayLessThan(int[] numbers, int limit) {

       

       //Text to be displayed before printing values less than the limit

       System.out.print("Values less than limit (" + limit + "): ");  

       //loop through the array and print numbers lower than the specified limit

       for(int i = 0; i < numbers.length; i++){

           if(numbers[i] < limit){

               System.out.print(numbers[i] + " ");

           }

       }

       

       //print a new line

       System.out.println();

   }

   

   public static void displayHigherThanAverage(int[] numbers) {

       //initialize the average variable

       double average = 0.0;

       

       //initialize the sum variable

       int sum = 0;

       

       

       //loop through the array and add each element to sum

      for(int i = 0; i < numbers.length; i++){

           sum += numbers[i];

       }

       

       //calculate the average

      average = sum / numbers.length;

       

       //Message to be displayed before printing the values higher than the average

       System.out.print("Values higher than average (" + average + "): ");

       

       

       //loop through the array and print numbers higher than the calculated average

      for(int i = 0; i < numbers.length; i++){

           if(numbers[i] > average){

               System.out.print(numbers[i] + " ");

           }

       }

       

       //print a new line

       System.out.println();

   }

   

}

Sample Output:

Numbers in the array: 12 15 34 67 4 9 10 7  

Reverse of the array numbers: 7 10 9 4 67 34 15  

Sum: 158

Values less than limit (12): 4 9 10 7  

Values higher than average(19.0):34 67

Explanation:

The code above contains comments explaining important parts of the code. Kindly go through the comments. A sample output, arising from running the application, has also been added to ace understandability.

A field is a group of related records that can be identified by the user with a name, type, and size.

Answers

Answer: False

Explanation:

The statement that a field is referred to as a group of related records which can be identified by the user with a name, type, and size is wrong.

The above definition represents a table. The group of related records is referred to as a table. On the other hand, a field refers to a set of data values, which are of identical data type.

__' the low level language? a.machine and assembly c.3G and 4G d.machine and 4gl​

Answers

Answer:

a. machine and assembly.

Explanation:

An instruction set architecture (ISA) can be defined as series of native memory architecture, instructions, addressing modes, external input and output devices, virtual memory, and interrupts that are meant to be executed by the directly.

Basically, this set of native data type specifies a well-defined interface for the development of the hardware and the software platform to run it.

A software can be defined as a set of executable instructions (codes) or collection of data that is used typically to instruct a computer how to perform a specific task and to solve a particular problem.

Machine and assembly are referred to as the low level programming language used in writing software programs or applications with respect to computer hardware and architecture. Machine language is generally written in 0s and 1s, and as such are cryptic in nature, making them unreadable by humans. Also, assembly language use commands written in English such as SUB, MOV, ADD, etc.

On the other hand, a high level language can be defined as a programming language which is generally less complex than a machine (low level) language and easy to understand by the end users (programmers).

This ultimately implies that, a high level programming language is typically a user friendly language and as such simplifies coding or programming for beginners.

Some examples of high level programming language are Python, Java, C#, Ruby, Perl, Visual Basic, PHP, Cobol, C++, Fortran, Javascript, etc.

________________risk in payment system requires improvements in the security framework. [ ]
a)Fraud or mistakes b)Privacy issues c)Credit risk d) All of the above.

Please write the answer for 15 points

Answers

Answer:

D. all of the above

Explanation:

sana nakatulong

Which keyboard shortcut do we use to turn on APC?​

Answers

Answer:

ctrl p I gusse hop it helps

bye know have a great day

Explanation:

The L-exclusion problem is a variant of the starvation-free mutual exclusion problem. We make two changes: as many as L threads may be in the critical section at the same time, and fewer than L threads might fail (by halting) in the critical section. An implementation must satisfy the following conditions:_____.
L-Exclusion: At any time, at most L threads are in the critical section.
L-Starvation-Freedom: As long as fewer than L threads are in the critical section, then some thread that wants to enter the critical section will eventually succeed (even if some threads in the critical section have halted).
Modify the n-process Bakery mutual exclusion algorithm to turn it into an L-exclusion algorithm. Do not consider atomic operations in your answer. You can provide a pseudo-code solution or written solution.

Answers

Answer:

The solution is as follows.

class LFilters implements Lock {

int[] lvl;

int[] vic;

public LFilters(int n, int l) {

lvl = new int[max(n-l+1,0)];

vic = new int[max(n-l+1,0)];

for (int i = 0; i < n-l+1; i++) {

lvl[i] = 0;

}

}

public void lock() {

int me = ThreadID.get();

for (int i = 1; i < n-l+1; i++) { // attempt level i

lvl[me] = i;

vic[i] = me;

// rotate while conflicts exist

int above = l+1;

while (above > l && vic[i] == me) {

above = 0;

for (int k = 0; k < n; k++) {

if (lvl[k] >= i) above++;

}

}

}

}

public void unlock() {

int me = ThreadID.get();

lvl[me] = 0;

}

}

Explanation:

The code is presented above in which the a class is formed which has two variables, lvl and vic. It performs the operation of lock as indicated above.

Write a C program that right shifts an integer variable 4 bits. The program should print the integer in bits before and after the shift operation. Does your system place 0s or 1s in the vacated bits?

Answers

Solution :

#include<[tex]$\text{stdio.h}$[/tex]>

#include<conio.h>

void dec_bin(int number) {

[tex]$\text{int x, y}$[/tex];

x = y = 0;

for(y = 15; y >= 0; y--) {

x = number / (1 << y);

number = number - x * (1 << y);

printf("%d", x);

}

printf("\n");

}

int main()

{

int k;

printf("Enter No u wanted to right shift by 4 : ");

scanf("%d",&k);

dec_bin(k);

k = k>>4; // right shift here.

dec_bin(k);

getch();

return 0;

}

Which of the following best explains how an analog audio signal is typically represented by a computer?
a. An analog audio signal is measured at regular intervals. Each measurement is stored as a sample, which is represented at the lowest level as a sequence of bits.
b. An analog audio signal is measured as a sequence of operations that describe how the sound can be reproduced. The operations are represented at the lowest level as programming instructions.
c. An analog audio signal is measured as input parameters to a program or procedure. The inputs are represented at the lowest level as a collection of variables.
d. An analog audio signal is measured as text that describes the attributes of the sound. The text is represented at the lowest level as a string.

Answers

Answer:

A. An analog audio signal is measured at regular intervals. Each measurement is stored as a sample, which is represented at the lowest level as a sequence of bits.

Explanation:

I took the test

Which work habits should you follow to increase work efficiency and avoid health issues?

Answers

Answer:

Just get good sleep, eat breakfast, and exercise.

Answer:

take periodic breaks and alternate between tasks

A collection of computers and other hardware devices that are connected together to share hardware, software, and data, as well as to communicate electronically with one another? Explain.

Answers

Here you go.....................

How can you ensure that the website you are using is secured?
A.
website begins with http://
B.
website begins with https:// and has a green padlock
C.
website doesn’t have any padlock icon
D.
website has a red padlock icon

Answers

The answer is B: website begins with https:// and has a green padlock

2.1 A friend is interested in installing a wireless LAN in her small business. She has about a dozen employees. You are setting up an 802.11g wireless access point for her business. Your aggregate throughput is only about 6 Mbps. List at least two possible reasons for this low throughput.

Answers

Answer:

The two reasons for low throughput are as follows:

1-Low throughput is due to the fall of throughput is more with distance from the source.

2-The throughput is shared by multiple hosts and they are all using at the same time.

Explanation:

As the aggregate throughput of the 802.11g wireless access point is same, thus when you go farther from it or the number of uses increases, the overall value of individual throughput decreases.

Select the best ansiver for each question below
c. Linux
c. operational interference
2. What type of software works with users, application software, and computer hardware
handle the majority of technical details?
a Application
b. Desktop
d. system
The ability to switch between different applications stored in memory is called
a Diversion
b. Multitasking
d. programming
Graphic representations for a program, type of file, ar function:
a. App
e image
b. Icon
d. software
The operating system based on Linux, designed for Netbook computers, and focused on
Internet connectivity through cloud computing:
a Chrome
c. Unix
b. Mac
d. Windows
Programs that coordinate computer resources, provide an interface, and run applicatio​

Answers

Answer:

the answer is going to be system

is used for finding out about objects, properties and methods​

Answers

Answer:

science

Explanation:

To specify the data sets you want to see for your particular user, you create or select a
d
Select one:
a. Filter
b. View
c. Switch
d. Scope

Answers

Answer:

B

Explanation:

Implement the function _isPalindrome() in palindrome.py, using recursion, such that it returns True if the argument s is a palindrome (ie, reads the same forwards and backwards), and False otherwise. You may assume that s is all lower case and doesn’t include any whitespace characters.

Answers

Answer:

The function is as follows:

def _isPalindrome(stri) :

  if len(stri) == 0:

     return True

  if stri[0] == stri[len(stri) - 1]:

     return _isPalindrome(stri[1:len(stri) - 1])

  else:

     return False

Explanation:

This defines the function

def _isPalindrome(stri) :

If the string is empty, then it is palindrome

  if len(stri) == 0:

     return True

This checks if the characters at alternate positions are the same.

If yes, it calls the function to check for other characters

  if stri[0] == stri[len(stri) - 1]:

     return _isPalindrome(stri[1:len(stri) - 1])

If otherwise, the string is not palindrome

  else:

     return False

is the minimum level of security mechanism in a
system.
Select one:
O Baseline
O Security model
O Security policy
O Reconnaissance​

Answers

Answer:

Security policy is the minimum

Explanation:

help meeeee pleaaaseee ​

Answers

Answer:

just drop out that the easiest solution

Rick is a fan of logic-based games. However, he is bored of the classic ones, like Sudoku and Mastermind, since he has solved so many of them. Recently he found a new game in which one is given a string with some question marks in it. The objective is to replace all of the question marks with letters (one letter per question mark) in such a way that no letter appears next to another letter of the same kind.
Write a function:
def solution(riddle)
that, given a string riddle, returns a copy of the string with all of the question marks replaced by lowercase letters (a-z) in such a way that the same letters do not occur next to each other. The result can be any of the possible answers as long as it fulfils the above requirements.
Examples:
1. Given riddle = "ab?ac?", your function might return "abcaca". Some other possible results are 'abzacd", "abfacf".
2. Given riddle = "rd?e?wg??", your function might return "rdveawgab".
3. Given riddle = "????????", your function might return "codility".
Write an efficient algorithm for the following assumptions:
• the length of the string is within the range [1..100,000);
• string riddle consists only of lowercases letters (a - z) or '?';
• it is always possible to turn string 'riddle' into a string without two identical consecutive letters.
1 # you can write to stdout for debugging purposes, e.g.
2 # print("this is a debug message")
3
4 def solution (riddle):
5
6 # write your code in Python 3.6
7 pass

Answers

Answer:

The function is as follows:

import random

import string

def solution(riddle):

   s = list(riddle)

   for i in range(len(riddle)):

       alpha = "".join(random.choice(string.ascii_letters) for x in range(1))

       alpha = alpha.lower()

       if s[i] == '?':

           if i > 0 and i < len(s)-1:

               if s[i+1] != alpha:

                   s[i] = alpha

               elif s[i-1] != alpha:

                   s[i] = alpha

               else:

                   i=i

           else:

               if i == 0:

                   if s[1] != alpha:

                       s[i] = alpha

                   else:

                       i = i

               else:

                   if s[i-1] != alpha:

                       s[i] = alpha

                   else:

                       i = i

   riddle = ""

   for ele in s:

       riddle+=ele

   

   return riddle

Explanation:

See attachment for explanation where comments are used to explain some lines

In this exercise we have to use the knowledge of the python language to write the code, so we have to:

The code is in the attached photo.

So to make it easier the code can be found at:

import random

import string

def solution(riddle):

  s = list(riddle)

  for i in range(len(riddle)):

      alpha = "".join(random.choice(string.ascii_letters) for x in range(1))

      alpha = alpha.lower()

      if s[i] == '?':

          if i > 0 and i < len(s)-1:

              if s[i+1] != alpha:

                  s[i] = alpha

              elif s[i-1] != alpha:

                  s[i] = alpha

              else:

                  i=i

          else:

              if i == 0:

                  if s[1] != alpha:

                      s[i] = alpha

                  else:

                      i = i

              else:

                  if s[i-1] != alpha:

                      s[i] = alpha

                  else:

                      i = i

  riddle = ""

  for ele in s:

      riddle+=ele

  return riddle

See more about python at brainly.com/question/26104476

what are the difference between bit address 7ch and byte address 7ch

Answers

so a byte address can only send  a get bytes (8 bits)

when a bit address can be more detailed as it can send a get not only bytes but bits also

-scav

which shortcut can we use to make directional heading of a cuboid more obvious while in the lidar view​

Answers

Answer:

cutting across

Explanation:

Which tab should you click if you want to access the Show All Comments option in a worksheet?

Home
Page Layout
Review
View

Answers

Answer: Review

Because you want to review the comments

Answer:

C.) Reivew

Explanation:

Doing it on EDG now!

Best luck to yall :3

Have a good day and byee

Other Questions
a.8. Sarah has a garden that is 4 feet by 3 feet. What is the perimeter of Sarah's garden?16 feetb. 7 feetc. 14 feetd. 9 feet Which company provides a crowdsourcing platform for corporate research and development?OA.MTurkOB.WikiAnswersO C.MediaWikiOD.Innocentive what is the full form of CRT Helppp this is a Algebra question The length of a garden is 6 feet more than the width. The area is 40 square feet. write an algebraic equation to determine the length and width of the garden. What is the length, in feet, of the garden? Which of the following best explains how an analog audio signal is typically represented by a computer?a. An analog audio signal is measured at regular intervals. Each measurement is stored as a sample, which is represented at the lowest level as a sequence of bits.b. An analog audio signal is measured as a sequence of operations that describe how the sound can be reproduced. The operations are represented at the lowest level as programming instructions.c. An analog audio signal is measured as input parameters to a program or procedure. The inputs are represented at the lowest level as a collection of variables.d. An analog audio signal is measured as text that describes the attributes of the sound. The text is represented at the lowest level as a string. Solve. 1/2(4x + 2/5) = 4/5 Please help due tonight!!! NO LINKS PLEASE they will be flagged.When 57,816 J of heat are transferred to a 240-g of an unknown metal, its temperature increases from 32C to 164 C. Identify the metal.If there is a link and you can't answer please put it in the comments I really need help!!! An inclined walkway leading to a new building is to rise 11 inches for each horizontal distance of 22 feet. Write this slope as a grade. (Round to the nearest tenth of a percent if necessary.) Which statement best completest this diagram? Cause - The confederacy wins major battles early in the civil war.Effect - ?A. Confederate forces launch a failed invasion of the north.B. President Lincoln issues the emancipation proclamation. C. Union general decide to give up on the anaconda plan. D. Most of the border states vote to secede from the union. Please help me, please I will give u the highest raigung A certain television is advertised as a 21-inch TV (the diagonal length). If the height of the TV is 13 inches, how wide is the TV? Round to the nearest tenth of an inch. A parabola opening up or down has vertex (0, 0) and passes through (-6,-9).Write its equation in vertex form.Simplify any fractions PLEASE HELP i will give brainliest 10 ft5 ft2 ftFind area!!! The triangles are congruent by the SSS congruence theorem. Triangles A B C and D E C are connected at point C. Triangle A B C is reflected across B C and then is rotated about point C to form triangle D E C. Which rigid transformation(s) can map TriangleABC onto TriangleDEC? Garrett Company provided the following information: Product 1 Product 2 Units Sold 10,000 20,000 Price $20 $15 Variable cost per unit $10 $10 Direct fixed cost $35,000 $75,000 Common fixed cost totaled $46,000. Garrett allocates common fixed cost to Product 1 and Product 2 on the basis of sales. If Product 2 is dropped, which of the following is true?a. Sales will increase by $300,000.b. Overall operating income will increase by $2,600.c. Overall operating income will decrease by $25,000.d. Overall operating income will not change.e. Common fixed cost will decrease by $27,600.Jennings Hardware Store marks up its merchandise by 30%. If a part costs $25.00, which of the following is true?a. The price is $7.50.b. The markup is $32.50.c. The price is $32.50.d. The markup is pure profit.e. All of these choices are correct. Steve has a hammer that is 0.29 meters long. Which expression is equal to the length, in meters, of Steve's hammer? Which item is discounted by more than 15%A. $199.99 smartphone on sale for $167.99B. $28,100 car on sale for $24,750C. $58 jeans on sale for $50D. $1.99 song download on sale for $1.75 Annabelle is employed as an administrator for GRM Industries. She noticed that her Box 1 and Box 3 amounts on her W-2 were different.b Employer identification number (EIN)c Employer'd name, address, and ZIP code 1 Wages, tips, other compensation 2 Federal income tax withheld3 Social security wages 4 Social security tax withheldWhat is a reason why the amounts in boxes 1 and 3 would be different?a) Annabelle received tips, which are not subject to Social Security taxes.b) Annabelle has contributed to a pre-tax 401(k) that reduced her taxable wages.c) Annabelle changed her withholding allowances on her W-4.d) Annabelle's wages were subject to a pre-tax garnishment.