Click here to Skip to main content
15,882,113 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am working on an app using kotlin in android studio. I have two activities. One activity accepts the age the the user inputs and then it takes me to another activity that would show the age, birthstone, and Chinese Zodiac sign.
What i am having trouble doing is finding how to do the age, birthstone and zodiac part. Can i get some guidance please?

What I have tried:

For the first activity i have
class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {

val sendDOB = findViewById<EditText>(
val sendbutton = findViewById<Button>(

        sendbutton.setOnClickListener {
            val dob = sendDOB.text.toString()
            val intent = Intent(this,
            intent.putExtra("DOB", dob)

For the second activity i have

<pre>class Birthdaycard : AppCompatActivity() {

    companion object {
        const val NAME_EXTRA = "NAME"
        const val DOB_EXTRA = "DOB"

    override fun onCreate(savedInstanceState: Bundle?) {

        val dob = intent.getStringExtra(DOB_EXTRA)

        val dobTextView = findViewById<TextView>(
        dobTextView.text = dob

        // calculate and display age, birthstone, and zodiac sign here

Updated 31-Jan-23 22:15pm
[no name] 1-Feb-23 0:22am
chilly45 1-Feb-23 0:47am    
Thank you for the link but um what does this have do with coding , as in the programming language kotlin?
[no name] 1-Feb-23 11:59am    
Tables ... you can't code "stones and signs" out of thin air.
David Crow 1-Feb-23 15:59pm    
If you had an array of birthstones:
String[] stones = { "Garnet", "Amethyst", "Aquamarine", "Diamond" ... };
Then you would simply access that array using the month value:
stones[birthMonth - 1];

1 solution

See Working with Age: it's not the same as a TimeSpan![^] for age calculation. As to the birthstone and zodiac parts, you just need to Google for the table of dates that provide the information.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900