Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void report_year(List<Account> list1) {
- int current_year = 2017; //Current year of the bank
- int max_year = 4; //How many year to check
- int count_4 = 0; //Count how many 4 years acc
- foreach (Account x in list1) { //Init loop
- string first_date = x.date; //x.date assign to first_date for easier to do thing
- string[] date_split = first_date.Split('-'); //Split between text with ' - ' and then add each one to Array
- int date_selected = Int32.Parse(date_split[2]); //[20,6,2011] select the 3rd as it is the year and then convert to Int andddd then assign to date_selected
- int cal_date = current_year - date_selected; //Calculate
- if (cal_date > max_year) { //Check if it is more than 4 year
- Console.WriteLine("Account that has more than 4 year : "+x.name); //Write Name
- count_4++; //Increase counter
- }
- }
- Console.WriteLine("Number of account with more than 4 year of banking : " + count_4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement