Skip to content

Latest commit

 

History

History
121 lines (121 loc) · 7.16 KB

LifeSImulator.md

File metadata and controls

121 lines (121 loc) · 7.16 KB

LifeSimulator

Skill Value
Logical Control Structures +10 Levels
Using Primitive Variable Types +2 Levels

Objective

To write a computer program that accurately simulates all of your major life decisions.

Materials

String, Math.random(), if-else,, switch

Methods

Write a computer program that steps a person through major life events. The major choices in life (inside the simulation) are as follows:

  • What job do you wish to have?
    • Business Man
    • Artist
    • Engineer
    • Helping Profession
  • Do you wish to marry?
  • Do you wish to have children?
  • Do you wish to follow rules or do you wish to break them?
  • Do you wish to keep in touch with your friends?
  • Do you wish to meaningfully contribute to society?
  • Do you wish to save money or spend lavishly?

Of course, we don't always get what we hope or plan for in life; in fact, more often than not we are treated to the unexpected. Your program will account for this using Math.random(). First your program will ask the person about their aspirations. You will want to start by asking the name of the person. Next you will ask each question above and catalog the answers. Note that there are only four choices for career. Based on their answers you will produce a life story for that person. The life story will be told in a paragraph that describes what happened in their life. The content of the text will be colored by how what they desired for their life contrasted with what eneded up actually happening. Developing this paragraph to be output to the screen will help you hone your logical operator and conditional statement skills. It will actually force you to master them.

Catalogued next are the probabilities:

For each question you will invoke Math.random() to see if they get their chosen answer. Each outcome has a particular weight or chance of coming true. For the job, there is a 30% chance they will become a business man, a 30% chance they will be in the helping professions, a 10% chance they will become an artist, and a 5% chance they will become an engineer. There is also a 5% chance they will become chronically unemployed. If the person becomes a business man, there is an 70% chance they will become rich and a 30% chance they will become middle class. If they become an Artist there is a 90% chance they will be poor and a 10% chance they will become rich. If they become an engineer, there is a 100% chance they will become rich. If they join the helping professions, there is a 100% chance they will be middle class. The business man and the engineer have a 30% chance of having an existential crisis and living a meaningless life. The artist and the helping professionals have a 100% chance of living a meaningful life.

There is a 50% chance the person will marry or not marry

There is a 25% chance the person will get divorced

There is a 30% chance they will have no children and a 10% chance of having 1 child, 10% of having 2 children, 10% chance of having 3 children, 10% chance of having 4 children, 10% chance of having 5 children, a 10% chance of having 6 children, and a 10% chance of having 7 children. Each child gets a gender and a name that must be described in the output. The gender and name is not chosen by the user but by the life simulator

Whether or not they follow the rules always ends up happening as they choose 100% of the time.

If the user chooses not to follow the rules, there is a 30% chance they will end up in jail but a 100% chance they will become rich. If they do follow the rules, there is a 1% chance they will end up in jail but there chances of becoming rich follow the same chances as their originally chosen profession.

There is an 70% chance they will stay in touch with their friends.

There is a 100% chance they will contribute or not contribute to society based on their choice. If they do not contribute to society there is a 20% increased risk of having an existential crisis and living a meaningless life. If they do contribute to society, there is a 20% reduced chance that they will be able to retire. If they become rich and they did not contribute to society, there is an 80% chance that they will be hated by everyone and go down poorly in history.

There is a 100% chance they will save money or spend lavishly based on their choice. If they save money, there is a 100% chance they will have a home and have a nice retirement. If they spend lavishly, they will accumulate lots of nice things but there is a 10% chance they will become homeless and a 20% chance they will have nothing left for retirement and need to work to the end of their life.

Data

The choices and preferences of the user.

Results

A life well-lived. After asking all of the questions to the user. The program should calculate the life of the user based on the probabilities above. A paragraph should be produced describing the life the person lived. Anytime their life does not go the way they desired, you need to color the paragraph with happiness, disappointment, or compromising and rationalization to account for the success or failure of their dreams. Make sure the final paragraph contains the following:

  • The name of the person
  • Whether or not they married and the name of their significant other
  • The profession the person landed in
  • Whether or not they became rich
  • Whether or not they went to jail
  • Whether or not they became homeless
  • Whether or not they were able to retire
  • Whether or not they had children, if so, how many, their genders and names
  • Whether or not they stayed in touch with their friends
  • Whether or not they contributed to society
  • Whether or not society hates or loves them at the end of their life
  • Whether they had lots of nice material posessions

Analysis

There are a lot of ways to go about writing the logic for this program. The design is very much up to the individual programmer. That being said, there are easy ways to write the logic and there are hard ways, choose wisely!

Conclusion

Congratulations you just wrote an interactive life simulator! In the process, you have mastered logical operators and conditionals!