Friday, July 31, 2009

Java question?

what are the two distinct syntax errors (each occuring multiple times)








import java.util.Scanner;


public class MaxMinRatio {


public static void main( String [] args ) {


Scanner in = new Scanner(System.in);


a = in.nextInt();


b = in.nextInt();


c = in.nextInt();


int min;


int max;


max = min = a;


if b %26gt; max { max = b; }


if c %26gt; max { max = c; }


if min %26gt; b || min %26gt; c {


min = b;


} else min = c;


System.out.println("ratio = " + max / min);


}


}

Java question?
Hi u must always use paranthesis for when keeping a condition.So put paranthesis to all your if conditions.





if(b%26gt;max)


if(c%26gt;max)


if(min%26gt;b||min%26gt;c)








Secondly i dont see declaring a,b,c in your main method which you have used.So declare them as ints.
Reply:Well done, way to sell of your dignity and do someone else's homework for them. Report It

Reply:you have to enclose each condition in parentheses. for example:


b %26gt; max should be (b %26gt; max) or min %26gt; b || min %26gt; c should be


(min %26gt; b || main %26gt; c)...
Reply:Why don't you compile it and see? They're pretty obvious.


No comments:

Post a Comment