Skip to content
Open
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions learning-java-2825378.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Binary file added out/production/learning-java-2825378/Main.class
Binary file not shown.
30 changes: 30 additions & 0 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -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);

}
}