From 8e070e4af8d688341f867071db41501d06b5b637 Mon Sep 17 00:00:00 2001 From: "github-classroom[bot]" <66690702+github-classroom[bot]@users.noreply.github.com> Date: Tue, 13 Oct 2020 12:28:48 +0000 Subject: [PATCH 1/2] Setting up GitHub Classroom Feedback From 23b682410bf5569ca9f0ada2c24f407e8cbb2573 Mon Sep 17 00:00:00 2001 From: EricLam414 <71828524+EricLam414@users.noreply.github.com> Date: Wed, 14 Oct 2020 08:30:38 -0400 Subject: [PATCH 2/2] Code from old document --- Shapes.java | 59 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/Shapes.java b/Shapes.java index 8090866..2dbc793 100644 --- a/Shapes.java +++ b/Shapes.java @@ -1,25 +1,52 @@ -import java.util.*; +import java.util.Scanner; +import java.lang.Math; -public class Shapes{ +class Shapes{ public static void main(String[] args) { Scanner input = new Scanner(System.in); - System.out.print("Enter the side length: "); + + System.out.print("What is the side length for squares? "); double side = input.nextDouble(); + square(side); - } - /* - * N: square - * P: to calculate the area of any square - * I: a side measure (double) - * R: - */ - public static void square(double s){ - //side times side - double a = s * s; + System.out.print("What is the base for triangles? "); + double base = input.nextDouble(); + System.out.print("What is the height for triangles? "); + double height = input.nextDouble(); + + triangles(base, height); + + System.out.print("What is side 1 triangles? "); + double side1 = input.nextDouble(); + System.out.print("What is side 2 triangles? "); + double side2 = input.nextDouble(); + System.out.print("What is side 3 triangles? "); + double side3 = input.nextDouble(); + + trianglesSides(side1, side2, side3); - //generate some output - System.out.println("A square with side " + s + " has an area of " + a); - }//close square method + System.out.print("What is the radius for the circle? "); + double radius = input.nextDouble(); + circle(radius); + } + public static void square(double s){ + double a = s * s; + System.out.println("A square with a side length of " + s + " has an area of " + a); + } + public static void triangles(double b, double h){ + double a1 = (1/2.0) * b * h; + System.out.println("A triangle with a base of " + b + " and a height of " + h + " has an area of " + a1); + } + public static void trianglesSides(double s1, double s2, double s3){ + double s = (s1 + s2 + s3) / 2.0; + double a = ((s) * (s - s1) * (s - s2) * (s - s3));; + double area = Math.sqrt(a); + System.out.println("A triangle with sides of " + s1 + "," + s2 + "," + s3 + " has an area of " + area); + } + public static void circle(double r){ + double a = Math.PI * r * r; + System.out.println("A circl with the radius of " + r + " has an area of " + a); + } }