- Joined
- Sep 25, 2012
- Messages
- 1
- Reaction score
- 0
So, we're given two classes originally.
public class Innocent
{
public static void main(String[] args)
{
String iAmGiving = "honor";
String result = Evil.bargain(iAmGiving);
System.out.println("Oh Woe! All I have received is " + result);
double sum = Evil.plus(2, 2.0);
System.out.println(sum);
System.out.println(Evil.plus(3, 4.5));
}
}
and
public class Evil
{
static public String bargain(String whatIsGiven)
{
System.out.println("Aha! I have received your " + whatIsGiven);
String whatIsReturned = "despair";
return whatIsReturned;
}
static public double plus(int a, double b)
{
return a + b;
}
}
And the assignment section I don't understand is where it asks me to do this:
1.)Add a method to Evil that has int[] as an argument which returns the sum of the first three elements in the array.
2.)In Innocent.main(), create a local variable array with at least 3 initialized elements (curly braces!)
3.)Add a call to your new Evil method using the array for the argument. Print the result.
I keep getting error messages like <identifier> expected. Please help!
public class Innocent
{
public static void main(String[] args)
{
String iAmGiving = "honor";
String result = Evil.bargain(iAmGiving);
System.out.println("Oh Woe! All I have received is " + result);
double sum = Evil.plus(2, 2.0);
System.out.println(sum);
System.out.println(Evil.plus(3, 4.5));
}
}
and
public class Evil
{
static public String bargain(String whatIsGiven)
{
System.out.println("Aha! I have received your " + whatIsGiven);
String whatIsReturned = "despair";
return whatIsReturned;
}
static public double plus(int a, double b)
{
return a + b;
}
}
And the assignment section I don't understand is where it asks me to do this:
1.)Add a method to Evil that has int[] as an argument which returns the sum of the first three elements in the array.
2.)In Innocent.main(), create a local variable array with at least 3 initialized elements (curly braces!)
3.)Add a call to your new Evil method using the array for the argument. Print the result.
I keep getting error messages like <identifier> expected. Please help!