+ 3
[Solved] So close.. Determining age via current date and user input
I made a class that uses <ctime> to get the current date. I also use <sstream> to reformat the user inputted birthday (MM/DD/YYYY). I am getting an output but I don't believe I am using ctime correctly.. Any help? Please check attached code. Thank you! https://code.sololearn.com/ctV45MQa0b79/?ref=app
1 Antwort
+ 1
Thank you so much for taking the time to go through my code, extremely helpful!! This has been the most difficult code I've attempted since I started learning with SoloLearn almost 3 weeks ago, so I was unsure if I could even get this to start compiling from concept stages, but your notes will help me take it to the next level :) Will update later today when I have time.
EDIT: I fixed it! I did have to adjust the logic for calculating age to this:
age = -1;
currentDate();
if(currentMonth >= month){
if(currentMonth == month){
if(currentDay >= day){
age = currentYear - year;
}
} else if (currentMonth > month){
age = currentYear - year;
}
}
if(age == -1)
age = currentYear - year - 1;
Thank you again for your help.