Yeah! I've been struggling with this thing since last Friday, and after moving things around it compiled and ran correctly. Thanks again!
However, I want to make sure I really comprehend what the error was there, so if you (or anyone else) could explain what was wrong with a little more detail, I'd be so grateful.
Here's my code now:
//
//
// CS201 Practice Lab Midterm Exam
//
//
import java.util.Scanner;
public class MyClass456
{
public static void main (String[] args)
{
Scanner scan = new Scanner(System.in);
MyClass456 myObject = new MyClass456(); // Replace NNN with 456.
// At the actual exam use your test number.
int n1, n2, n3, i;
//** The method displayHeading displays your name, BlazerID, course name, and your
//** row number and seat number. The course name is passed as a parameter. ** 1 point
myObject.displayHeading("CS-201");
//** method testSigns(n1,n2,n3) returns the String:
//** "All Positive or Zero" if all three parameters are zero or positive ( >= 0 )
//** "All negative" if all three parameters are negative ( < 0 )
//** "Postive and Negative" if parameters are mixed signs ** 4 points
//** Example: calling testSigns(-1,3,0) returns "Positive and Negative"
//** Example: calling testSigns(10,13,0) returns "All Positive or Zero"
//** Example: calling testSigns(-2,-7,-12) returns: "All Negative"
for (i = 0; i < 3; i++) // test method testSigns three times
{
System.out.print("\n\n** method testSigns **\n\nEnter the first positive," +
"negative, or zero integer: ");
n1 = scan.nextInt();
System.out.print("\nEnter the second positive, negative, or zero integer: ");
n2 = scan.nextInt();
System.out.print("\nEnter the third positive, negative, or zero integer: ");
n3 = scan.nextInt();
System.out.println("\n" + n1 + " " + n2 + " " + n3 + ": " +
myObject.testSigns(n1, n2, n3));
}
//** Method oddNumbers(n1, n2) displays the odd numbers
//** from integers n1 to n2 (inclusive)
//** The odd numbers are displayed one per line.
//** Examples: oddNumbers(1,5) displays: 1 oddNumbers(10,18) displays 11
//** 3 13
//** 5 15
//** ** 5 points 17
System.out.print("\n\nEnter the first integer: ");
n1 = scan.nextInt();
System.out.print("\n\nEnter the second integer: ");
n2 = scan.nextInt();
myObject.oddNumbers(n1,n2);
System.out.println();
}
public void displayHeading(String course)
{
System.out.println("\n\nBen Giles");
System.out.println("bengiles");
System.out.println(course);
System.out.println("Row Number: 2 Seat Number: 5\n");
}
public String testSigns(int x, int y, int z)
{
if (x >= 0 && y >= 0 && z >= 0)
return "All Positive or Zero";
else
if (x < 0 && y < 0 && z < 0)
return "All Negative";
else
return "Postive and Negative";
}
public void oddNumbers(int start, int finish)
{
while (start <= finish)
{
if (start % 2 != 0)
System.out.println(start);
start++;
}
}
}