O
O
Orkhan Hasanli2018-06-20 01:23:16
Java
Orkhan Hasanli, 2018-06-20 01:23:16

How to create a calculator from a spreadsheet?

Good day!
There is a table for calculating the sex of the child.
Table - https://kroshka.org.ua/images/stories/Pol_rebenka/... The
question is, how can I write an optimized code? For now I have implemented it like this:
blog.md7.info/calculators/konsolnaja-programma-dlj
... through nested switch cases.
Maybe you can simplify this task? For example, mapping or something else? The method of obtaining data is not so important, Scanner is also suitable, you can even get the value from the field (on android). The main thing is how to implement the calculator itself from the table ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-06-20
@azerphoenix

There is a table
<...>
Maybe you can simplify

Can. Or rather, there was no need to complicate anything - they would have transferred your table to the code as it was. Two-dimensional array. The first index corresponds to the month (it will only be necessary to subtract one from what the user enters), the second to the age (and here, respectively, subtract 18). All logic with switches will shrink to one line.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question