U2 lesson 5

This commit is contained in:
End Nightshade 2026-02-05 10:27:54 -07:00
parent 5420c97f30
commit f76c3022bb
No known key found for this signature in database
3 changed files with 54 additions and 0 deletions

View file

@ -0,0 +1,16 @@
/* Lesson 5 Coding Activity Question 1 */
import shapes.*;
public class U2_L5_Activity_One {
public static void main(String[] args) {
Circle c1 = new Circle(10.1);
Circle c2 = new Circle(14);
Circle c3 = new Circle(20.5);
System.out.println(c1);
System.out.println(c2);
System.out.println(c3);
}
}

View file

@ -0,0 +1,16 @@
/* Lesson 5 Coding Activity Question 3 */
import java.util.Scanner;
import shapes.*;
public class U2_L5_Activity_Three {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Type a side length:");
double length = scan.nextDouble();
RegularPolygon eq = new RegularPolygon(length);
RegularPolygon sq = new RegularPolygon(4, length);
System.out.println(eq + "\n" + sq);
}
}

View file

@ -0,0 +1,22 @@
/* Lesson 5 Coding Activity Question 2 */
import java.util.Scanner;
import shapes.*;
public class U2_L5_Activity_Two {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Type a number for length and width:");
double firstInput = input.nextDouble();
System.out.println("Type a length:");
double secondInput = input.nextDouble();
System.out.println("Type a width:");
double thirdInput = input.nextDouble();
Rectangle rect1 = new Rectangle(firstInput, firstInput);
Rectangle rect2 = new Rectangle(secondInput, thirdInput);
System.out.println(rect1);
System.out.println(rect2);
}
}