Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My Java code is getting errors in trying to get the following: Write a variation of the largestAbsVal method from the last exercise that takes

My Java code is getting errors in trying to get the following: Write a variation of the largestAbsVal method from the last exercise that takes three integers as parameters and returns the largest of their three absolute values. For example, a call of largest AbsVal(7, -2, -11) would return 11, and a call of (-4, 5, 2) would return 5.

One error is that it says that the int largestAbsVal is not applicable for the arguments (int, int, int).

A second error is that if I put a semicolon after int z, then the int x, y, and z are not initialized. But there is an error if I don't put a semicolon.

Could you please review my code below and critique what I am doing wrong? Thank you.

public class Chapter3 {

public static void main (String [] args) {

printPowersOf2();

int AbsVal=largestAbsVal (7, -2, -11);

int largeAbs=largestAbsVal (-4,5,2);

System.out.println();

System.out.println();

}

public static void printPowersOf2() {

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

System.out.print((int) Math.pow(2,i) + " ");

}

System.out.println();

}

public static int largestAbsVal() {int x; int y; int z {

x=Math.abs (x);

y=Math.abs (y);

z=Math.abs (z);

int large = Math.max(x, y);

large=Math.max(large, z);

return large;

}

} }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

please dont use chat gpt 5 9 4 .

Answered: 1 week ago