I need help with this seemingly simple homework problem!

Joined
Sep 26, 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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top