2016년 12월 11일 일요일

Help with making an age calculator?


I was hoping some one could possibly help me code an app that is able to tell you your exact age down to the second. I have a small amount of knowledge with coding in MIT App Inventor 2, so you'll have to bear with me. I have the app layout completed, but I'm completely stumped with the code. I have a clock component and see all of the blocks that you would use, I just don't know how to make it happen. When you press the 'Find my age button', it will take you to a second screen that displays your age. I understand a Tiny DB is required to transfer data between screens, but yet again, I am not sure how. I understand this will all have to be on one screen if it is too complicated to transfer the answer and all over to another screen. I will show screenshots of both of the screens at the bottom of this post. (Sorry if the first screen is confusing to look at. I wasn't sure how to put spaces between text boxes and such and didn't want the entire screen crammed together, so I used blank horizontal alignments.) The only coding I have done so far is for the clear button. Any help would be greatly appreciated, and if you need any extra info ask away, I will provide you with as much details as I can.
Screen Shot 2016-12-05 at 6.10.11 PM.png 표시 중

Screen Shot 2016-12-05 at 5.59.52 PM.png 표시 중
-- 
You might look at the example here which is not exactly what you want but perhaps good enough  https://groups.google.com/forum/#!searchin/mitappinventortest/calculate$20age/mitappinventortest/cwn1_Kj_wVY/8gpGS4R8DwAJ     Try the aia.

Perhaps before you continue your Project you should consider doing some tutorials about how to program?

Here are several issues that make your apparently simple app difficult even for seasoned users to program.  



How to pass values from one screen to another screen by Scott

Before starting to create another screen, think about is it really necessary?  If you use multiple screens you have to pass information between screen which means you will probably use a TinyDB control -- not simple for a beginner.   It would be better to build this on  a single screen.  See  Building apps with many screens and the reasons why a single screen is probably best  https://groups.google.com/forum/#!msg/mitappinventortest/ka-LS7wmWxs/wRbs70x2BgAJ   

Also you need to learn to switch screens responsibly as shown in Taifun's example:
      The recommended method of switching screens in App Inventor   if you are firm about using multiple screens.

To understand the Clock component, you might read http://ai2.appinventor.mit.edu/reference/components/sensors.html#Clock

To finish your project, you might consult the following resources to help you learn to use the AI2 tools:  A very good way to learn App Inventor is to read the free Inventor's Manual in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.  

There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  

How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling.

The MIT tutorials are here:  http://appinventor.mit.edu/explore/ai2/tutorials.html  

Have you read Dr. Wolber's book?  Have you done any tutorials?

-- 
Thank you for the help everyone, sorry for the long reply. I've moved everything to one screen so things are less complicated. I have indeed done some tutorials, I have been in an app developing class (we've used nothing but MIT2 so far) since August. My teacher isn't exactly the best at explaining things so I'm not as well developed as I should be. I've looked at the .aia for the file you attached and I'm wondering how I would show the other time values (months, weeks, days, hours, minutes, and seconds) instead of only the year being displayed. I've read up on the clock components and things make a bit more sense, though I'm still slightly confused on to how to do it all. Again, thank you for taking the time to respond to my post, I appreciate the help.

-- 
This is a different solution

Feel free to experiment.  It does not break the age in to  days + hours + minutes + seconds   if that is what you have to have.   You can use the days and the fractional part to convert the fractional day into hours and minutes and seconds remembering     24 hours in a day  60 minutes in an hour and 60 seconds in a minute ..... Purists will quibble about the 4 leap years in this example (or 3 depending on how you count) and how to handle it but I suspect this may be good enough?

--
Yes, this will be good enough. Thank you so much! Have a wonderful rest of the night sir.

-- 

댓글 없음:

댓글 쓰기