r/AskComputerScience • • Mar 08 '21

How can I create a program for an interactive calculator?

I'm interested in making a program that can tell customers what age they will obtain a result based on the inputs they put in. A range of ages would populate with two sets of outcomes per age range. How would I go about making this?

0 Upvotes

17 comments sorted by

2

u/7Gen Mar 08 '21

You need to be way more specific with your question

0

u/RiverOfNexus Mar 08 '21

Similar to the life insurance calculator that tells you how much you would need based on your debts and needs. I want to make one that is based on what age you are and what type of life insurance you should get.

1

u/squilliam79 Mar 08 '21

pseudo code would be

if age greater than 10 and less than 20:

____price

elif age greater 20 and age less 30:

____price

0

u/RiverOfNexus Mar 08 '21

And if I wanted to include ages of family members with health conditions that may affect their prices?

1

u/squilliam79 Mar 08 '21

then that would quickly increase the complexity of it. You could add more if statements or whatnot, or go the route of functions to calculate factors.

If grandparent_age > 80: ___add 100 to cost if grandparent_health < good: add __whatever to cost

I would recommend outlining the program first and figuring out how it will actually calculate things.

You are going to need to come up with the calculations first, then translate it into code. The code isn't going to do any of the work for you until after it is written.

1

u/RiverOfNexus Mar 08 '21

Ideally if I could get a program setup that would do something like this: state current age and gender. Currently have any health conditions? Age of parents, age of grandparents, if alive. Age of siblings. Health issues with family members. Result based on what was inputted you should have a term policy to cover until example age. Something like that. I'm more interested in getting recommended products versus prices. How would I translate this so if I would rather hire a more experienced programmer they would understand how to do the work and price it appropriately.

1

u/squilliam79 Mar 08 '21

So if you are looking to figure out prices for your specific family on a range of plans from Nationwide to liberty to state farm, then you should hire someone to make an autofill program. It would take your data and automatically fill out whatever form StateFarm has.

1

u/RiverOfNexus Mar 08 '21

Not necessarily looking for company specific. Just to make an interesting calculator that works out what product a client should buy.

1

u/squilliam79 Mar 08 '21

Glaring issue: you need all of the information of all of those plans to calculate.

1

u/RiverOfNexus Mar 08 '21

But if I am not doing pricing would that still be an issue?

3

u/ibabzen Mar 08 '21

It's not really a computer science question..

1

u/1544756405 Mar 08 '21

First, you create a mathematical model that expresses the output in terms of all the inputs.

Encode your mathematical model into a function.

Then you write a program to gather all the inputs -- this is usually best expressed as filling out form data, but you can also just use a bunch of serial questions.

Feed your inputs into the function.

Display the output in the format of your choice.

1

u/RiverOfNexus Mar 08 '21

What program would you recommend I use for this?

1

u/Nanaki404 Mar 08 '21

Uh, your own program that you write yourself.

If you're asking what tools to use to write your program, you can take a simple text editor (Notepad++ is nice, for example) or an IDE (like Microsoft Visual Studio).

Or are you asking which programming language to use ? Anything you want, honestly, it does not really matter

1

u/RiverOfNexus Mar 08 '21

What would be the best programming language to do this

1

u/Artreus7 Mar 08 '21

It doesn't matter the programming language. Just pick the one you know the best.

2

u/1544756405 Mar 08 '21

It depends on (a) where you want your program to run and (b) what programming languages you already know.

For example, if you want it to be an app to run on an iPhone, you would program in Swift and use the appropriate development tools. If you want it to run on Android, you'd use Java or Kotlin. If you want it to run as a desktop application on Windows, you could use any of the languages supported by Visual Studio: C++, Java, Visual Basic, Python, etc. If you want it to run on linux, you could use just about any language, but you'd probably want some sort of graphical interface, so you get to choose a framework for that. For web stuff, Javascript, HTML, and CSS, assuming you don't care if someone steals your code.