Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

04 04b #29

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
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);

}
}