Conditional Operator "?:" not compiling
Code Java:
// Practical 7A (Revision) - Q
// Marcus Ward
// 26/10/2011
/* User will enter a number, and using the conditional
operator "?:" the program will display if pos. or neg. */
import java.util.Scanner;
public class PositiveOrNegativeNumber
{
public static void main(String[] args)
{
Scanner keyboardIn = new Scanner(System.in);
// declare variables
int digit;
// get user input
System.out.print("Enter a number: ");
digit = keyboardIn.nextInt();
System.out.println(digit>=0?"The number is positive":"The number is negative");
}
}
Re: Conditional Operator "?:" not compiling
Hi mwardjava92. Welcome to Java Programming Forums.
What compilation errors do you get?
This code works perfectly for me, you will need to provide a full explanation of the problem and include error outputs, we cannot fly blind.
Regards,
Chris
Re: Conditional Operator "?:" not compiling
Works fine for me too ...
application context
Re: Conditional Operator "?:" not compiling
Hi all,
Thanks for the replies. It was only an error in the installaton on jGrasp was the problem.
Forgive me as I'm only a beginner. :o
Regards.
mwardjava92