234k views
3 votes
Write a method maxmagnitude() with three integer parameters that returns the largest magnitude value. Use the method in the main program that takes three integer inputs and outputs the largest magnitude value.

1 Answer

7 votes

Answer:

def maxmagnitude(a, b, c):

return max(abs(a), abs(b), abs(c))

a = int(input("Enter an integer: "))

b = int(input("Enter an integer: "))

c = int(input("Enter an integer: "))

if a < 0 or b < 0 or c < 0:

print("Largest magnitude:", -maxmagnitude(a, b, c))

else:

print("Largest magnitude:", maxmagnitude(a, b, c))

since you didnt mention what program youre using im going to answer using python. if you would like me to amend please let me know!

User Ozzy
by
4.4k points