Created
August 29, 2015 21:48
-
-
Save alagalia/b66ded2848f9378016ca 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
package JavaSyntax; | |
import java.util.Scanner; | |
public class Problem1RectangleArea { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
int a = scanner.nextInt(); | |
int b = scanner.nextInt(); | |
System.out.println("Area:"+ a*b); | |
} | |
} |
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
package JavaSyntax; | |
import java.util.Scanner; | |
public class Problem2TriangleArea { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
int aX = scanner.nextInt(); | |
int aY = scanner.nextInt(); | |
int bX = scanner.nextInt(); | |
int bY = scanner.nextInt(); | |
int cX = scanner.nextInt(); | |
int cY = scanner.nextInt(); | |
int triangleArea = Math.abs((aX * (bY - cY) + bX * (cY - aY) + cX * (aY - bY)) / 2); | |
if (triangleArea != 0) { | |
System.out.println("The triangle`s area is: "+triangleArea); | |
} | |
else { | |
System.out.println("This points cannot form triangle!"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment