On my quiz, i was asked to write a method, called
public static boolean Order (int a, int b, int c), that returns true, if the integers a, b, and c are in ascending order, and false, otherwise.
For example, Order(12, 23, 99) returns true, and Order (3, 2, 13) returns false.
I got this one totally wrong.
Here's what I wrote.
public static boolean Order (int a, int b, int c)
{
if a%26lt;b
return true
if b%26lt;c
return true
if a%26lt;c
return true
I would so appreciate whoever is willing to fix this.
Another quiz question that i got wrong in my computer science class?
This should work.
public static boolean Order(int a, int b, int c)
{
if (a%26lt;b %26amp;%26amp; b%26lt;c)
return true;
else
return false;
}
Have fun with java!
Another quiz question that i got wrong in my computer science class?
i havent a clue but
if a%26lt;b
return true
if b%26lt;c
return true
if a%26lt;c
return true
will give you 3 trues or 1 true and 2 false etc
should you write it so you only get 1 true or 1 false ?
eg a%26lt;b%26lt;c
return true
Another quiz question that i got wrong in my computer science class?
if (a%26lt;b %26amp;%26amp; b%26lt;c %26amp;%26amp; a%26lt;c)
return true;
return false;
No comments:
Post a Comment