diff --git a/app/src/main/java/me/adamwlarson/class3/MainActivity.java b/app/src/main/java/me/adamwlarson/class3/MainActivity.java index 1993797..0bf7349 100644 --- a/app/src/main/java/me/adamwlarson/class3/MainActivity.java +++ b/app/src/main/java/me/adamwlarson/class3/MainActivity.java @@ -24,8 +24,89 @@ public void onCalculate(View view) { tView.setText(Integer.toString(centuryFromYear(year))); } - private int centuryFromYear(int year) { - //TODO add your code yere - return 0; - } + private int centuryFromYear(int year) { + if(year >= 2000) { + System.out.print("20"); + }else { + if(year >= 1900) { + System.out.print("19"); + }else { + if(year >= 1800) { + System.out.print("18"); + }else { + if(year >= 1700) { + System.out.print("17"); + }else { + if(year >= 1600) { + System.out.print("16"); + }else { + if(year >= 1500) { + System.out.print("15"); + }else { + if(year >= 1400) { + System.out.print("14"); + }else { + if(year >= 1300) { + System.out.print("13"); + }else { + if(year >= 1200) { + System.out.print("12"); + }else{ + if(year >= 1100) { + System.out.print("11"); + }else { + if(year >= 1000) { + System.out.print("10"); + }else { + if(year >= 900) { + System.out.print("9"); + }else { + if(year >= 800) { + System.out.print("8"); + }else { + if(year >= 700) { + System.out.print("7"); + }else { + if(year >= 600) { + System.out.print("6"); + }else { + if(year >= 500) { + System.out.print("5"); + }else { + if(year >= 400) { + System.out.print("4"); + }else { + if(year >= 300) { + System.out.print("3"); + }else { + if(year >= 200) { + System.out.print("2"); + }else { + if(year >= 100) { + System.out.print("1"); + }else { + System.out.print("0"); + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +