Problem

Playing CompilerDetermine the errors in each of the following segments. Fix the errors and...

Playing Compiler

Determine the errors in each of the following segments. Fix the errors and then

determine the output. Unusual formatting is not an error.

a.

public class WhatTheHey{   public static int method1(int x,y)   {     return x + y;   }   public int method2(double x, double y)   {      return int(x − y);   }   public static void main(String[] args)   {     System.out.println(“The output is: ”, method1(method2(7.1, 6.2), method1(2, 3)) “years of bad luck” );   }}


b. public class TheBookOnLove   {     public static void method1()     {         System.out.println(“I wonder who wrote the book on love”);     }     public static void method1(int x)     {         for (i = 0; i


c.

public class ThisComputesSomeWeirdStuff{     public static int method1(int a, int b)     {        if (a%2 == 0) return (a) else return (b)     }     public static int method2(int a, int b)     {        while (a ! = 1) {b++; a = a / 2;} return (b);     }     public static void main{String[] args}     {        System.out.println(method2(method1(3, 10), method1(16, 57)));        System.out.println(method2(method1(190, 10), method1(16, 57)));        System.out.println(method2(method2(3, 10), method1(16, 57)));        System.out.println(method1(method2(3, 10), method2(16, 57)));     }}


d.

public class ThisOneIsPrettyCool{     public static int method1(int w)     {        int count _ 0;        while (w != 1) if (w % 2 == 0)       {             w == w / 2;             count++;       }       else           w = 3 * w + 1;       return count;    }    public static void main(String[] args)    {       System.out.println(method1(10));       System.out.println(method1(7));    }}


e.

public class OkIveHadEnough{    public static double method1(int a) { return a / 2;}    public static double method1() {return 1.0;}    public static int method2(double x) {return 3 * (int)x;}    public static int method2() {return 0;}    public static void main(String[] args)    {       System.out.println(method2(method1()));       System.out.println(method1(method2()));       for (int j = 0; j = 10; j++)       {        System.out.println(method2(method1(j));        System.out.println(method1(method2(j)));    }   }}

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 6
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT