Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions day4.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
24 changes: 24 additions & 0 deletions day5.java
Original file line number Diff line number Diff line change
@@ -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();
}
}