Created
September 22, 2017 01:53
-
-
Save khayyamsaleem/f22f8050e728336d5e49e174869a0b45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Coordinates { | |
public static void main(String[] args){ | |
Scanner console = new Scanner(System.in); | |
System.out.println("x coordinate? "); | |
double x = console.nextDouble(); | |
int neg; | |
if (x < 0.0) { | |
System.out.print("y coordinate? "); | |
double y = console.nextDouble(); | |
if (y < 0.0) { | |
neg = 2; | |
System.out.println("negatives = " + neg); | |
} else { | |
neg = 1; | |
System.out.println("negatives = " + neg); | |
} | |
} else { | |
System.out.print("y coordinate? "); | |
double y = console.nextDouble(); | |
if (y < 0.0) { | |
neg = 1; | |
System.out.println("negatives = " + neg); | |
} else { | |
neg = 0; | |
} | |
System.out.println("negatives = " + neg); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment