diff --git a/day4.java b/day4.java new file mode 100644 index 0000000..ff4ec0f --- /dev/null +++ b/day4.java @@ -0,0 +1,44 @@ +import java.io.*; +import java.util.*; +public class Person { + private int age; + + public Person(int initialAge) { + // Add some more code to run some checks on initialAge + age = initialAge; + if (age < 0) { + System.out.println("Age is not valid, setting age to 0."); + age = 0; + } + } + + public void amIOld() { + // Write code determining if this person's age is old and print the correct statement: + if (age < 13) + System.out.println("You are young."); + else if (age >= 13 && age < 18) + System.out.println("You are a teenager."); + else + System.out.println("You are old."); + } + + public void yearPasses() { + // Increment this person's age. + age++; + } +public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int T = sc.nextInt(); + for (int i = 0; i < T; i++) { + int age = sc.nextInt(); + Person p = new Person(age); + p.amIOld(); + for (int j = 0; j < 3; j++) { + p.yearPasses(); + } + p.amIOld(); + System.out.println(); + } + sc.close(); + } +} \ No newline at end of file diff --git a/day5.java b/day5.java new file mode 100644 index 0000000..e5e71e1 --- /dev/null +++ b/day5.java @@ -0,0 +1,24 @@ +import java.io.*; +import java.math.*; +import java.security.*; +import java.text.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.regex.*; + +public class Solution { + + + + private static final Scanner scanner = new Scanner(System.in); + + public static void main(String[] args) { + int n = scanner.nextInt(); + scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); + for(int i=1;i<=10;i++){ + System.out.println(n+" x "+i+" = "+n*i); + } + + scanner.close(); + } +}