# Write program in MATLAB to determine age of person

1. Construct a program that will ask the user the current date and his/her birthday and display the number of days
they have been alive. You can ignore leap years.

## The Attempt at a Solution

I have little experience in MATLAB or programming in general, but a little help to get me started would be appreciated. Thanks

Related Engineering and Comp Sci Homework Help News on Phys.org
berkeman
Mentor
1. Construct a program that will ask the user the current date and his/her birthday and display the number of days
they have been alive. You can ignore leap years.

## The Attempt at a Solution

I have little experience in MATLAB or programming in general, but a little help to get me started would be appreciated. Thanks
Welcome to the PF.

How many days are there in each month? (Hint -- you will need to list each month)

How many days are there in each (non-leap) year?

What can you do with those sets of numbers, given their birthdate and current date, to find out how many days they've been alive.

Show us some initial work (can just be pseudo-code for now)...

I apologize for the absence of an attempt, but I don't even know what syntax to use or where to start. I've never programmed before and this is my first programming class for engineering. My professor said he would show us but I wanted to struggle a little bit first.

berkeman
Mentor
I apologize for the absence of an attempt, but I don't even know what syntax to use or where to start. I've never programmed before and this is my first programming class for engineering. My professor said he would show us but I wanted to struggle a little bit first.
In addition to the MATLAB resources that Mark44 pointed you to, often in programming, we do a first pass in "pseudocode" or just plain words to map out what we want the program to do. You don't need to dive straight into coding in C or Java or MATLAB or whatever. It helps you to stand back and see what the overall flow of the program should be.

So can you take a cut at what the program should do overall?

Like,

** Prompt & User inputs today's date in MM/DD/YYYY (or whatever) format

** Prompt & User inputs a birthdate in MM/DD/YYYY (or whatever) format

** Count up the number of days between the two dates