diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..e7e9d11d --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 00000000..dd2f277f --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +LearningJava \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..5217e29a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..b6f11837 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/learning-java-2825378.iml b/learning-java-2825378.iml new file mode 100644 index 00000000..c90834f2 --- /dev/null +++ b/learning-java-2825378.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/learning-java-2825378/Main.class b/out/production/learning-java-2825378/Main.class new file mode 100644 index 00000000..3b29f044 Binary files /dev/null and b/out/production/learning-java-2825378/Main.class differ diff --git a/src/Main.java b/src/Main.java new file mode 100644 index 00000000..4b93e162 --- /dev/null +++ b/src/Main.java @@ -0,0 +1,30 @@ +import java.util.Scanner; + +public class Main { + + public static void main(String[] args) { + + System.out.println("Let's calculate the area of a triangle"); + + Scanner input = new Scanner(System.in); + + System.out.println("Please input the base of the triangle (in inches)."); + double base = input.nextDouble() + + while (base <= 0) { + System.out.println("That's invalid. Please input the base of the triangle (in inches)."); + base = input.nextDouble(); + } + + System.out.println("Please input the height of the triangle (in inches)."); + double height = input.nextDouble(); + while (height <= 0) { + System.out.println("That's invalid. Please input the base of the triangle (in inches)."); + base = input.nextDouble(); + } + + double area = (base * height) / 2; + System.out.println("The area is " + height); + + } +}