Created
March 18, 2015 06:57
-
-
Save yoxisem544/98474a14b517a2ca3112 to your computer and use it in GitHub Desktop.
This file contains 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 Hey { | |
public static void main(String[] args) { | |
String[] months = {"January","Feburary","March","April","May","June","July","August","September","October","Novenber","December"}; | |
System.out.println(months[(int)(Math.random()*12)]); | |
} | |
} |
This file contains 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 Heyy { | |
public static void main(String[] args) { | |
int[] inputs = new int[3]; | |
int[] lott = new int[3]; | |
for (int i = 0; i < 3; i++) { | |
lott[i] = (int)(Math.random() * 10); | |
} | |
System.out.println("Please input three number to play the lottery: "); | |
Scanner s = new Scanner(System.in); | |
for (int i = 0; i < 3; i++) { | |
inputs[i] = s.nextInt(); | |
} | |
int matchs = 0; | |
for (int i = 0; i < 3; i++) { | |
if (inputs[i] == lott[0] || inputs[i] == lott[1] || inputs[i] == lott[2]) { | |
matchs += 1; | |
} | |
} | |
System.out.println(lott[0]); | |
System.out.println(lott[1]); | |
System.out.println(lott[2]); | |
if (inputs[0] == lott[0] && inputs[1] == lott[1] && inputs[2] == lott[2]) { | |
System.out.println("You win $12000 dollars."); | |
} else { | |
if (matchs == 3) { | |
System.out.println("You win $5000 dollars."); | |
} else if (matchs == 2) { | |
System.out.println("You win $2000 dollars."); | |
} else if (matchs == 1) { | |
System.out.println("You win $2000 dollars."); | |
} else { | |
System.out.println("You lose."); | |
} | |
} | |
} | |
} |
This file contains 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 Heyyy { | |
public static void main(String[] args) { | |
System.out.println("Enter x, y: "); | |
Scanner s = new Scanner(System.in); | |
int x = s.nextInt(); | |
int y = s.nextInt(); | |
if ( (x-1) * (y-1) > 100) { | |
System.out.println("outside circle."); | |
} else { | |
System.out.println("inside circle."); | |
} | |
} | |
} |
This file contains 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 Heyyyy { | |
public static void main(String[] args) { | |
System.out.println("first rec is always larger then second one."); | |
System.out.println("Enter first x, y, w, h: "); | |
Scanner s = new Scanner(System.in); | |
int x1 = s.nextInt(); | |
int y1 = s.nextInt(); | |
int w1 = s.nextInt(); | |
int h1 = s.nextInt(); | |
System.out.println("Enter second x, y, w, h: "); | |
s = new Scanner(System.in); | |
int x2 = s.nextInt(); | |
int y2 = s.nextInt(); | |
int w2 = s.nextInt(); | |
int h2 = s.nextInt(); | |
if (Math.abs(x1-x2) >= Math.abs(w1+w2) || Math.abs(y1-y2) >= Math.abs(h1+h2)) { | |
System.out.println("outside rec"); | |
} else if ((Math.abs(x1-x2)+w1 <= Math.abs(w1)) && (Math.abs(y1-y2)+h1 <= Math.abs(h1))) { | |
System.out.println("inside rec"); | |
} else { | |
System.out.println("overlap rec"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment