Skip to content
Open
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
14 changes: 7 additions & 7 deletions hackerrank/Day4.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@
import java.util.*;

public class Day4 {
private int age;
private int a;

public Day4(int initialAge) {
// Add some more code to run some checks on initialAge
if(initialAge<0){
System.out.println("Age is not valid, setting age to 0.");
age = 0;
a = 0;
}

else{
age = initialAge;
a = initialAge;
}

}

public void amIOld() {
// Write code determining if this person's age is old and print the correct statement:
if(age<13){
if(a<13){
System.out.println("You are young.");
}

else if(age>=13 && age<18 ){
else if(a>=13 && a<=19 ){
System.out.println("You are a teenager.");
}
else{
Expand All @@ -33,7 +33,7 @@ else if(age>=13 && age<18 ){

public void yearPasses() {
// Increment this person's age.
age = age + 1;
a = a + 1;
}

public static void main(String[] args) {
Expand All @@ -51,4 +51,4 @@ public static void main(String[] args) {
}
sc.close();
}
}
}