I am trying to develop a calculator program that inputs an arithmetic expression of the form number operator number = and computes the result of the expression. The expression will be evaluated from left to right not considering regular operator precedence. For example, the expression 14 – 5 * 3 = will produce 27.0. The value = displays the final

# Tag: double

## (Java) How do you check a string for two or more digit integers using .matches()?

The objective of this program is to return the atomic mass from a given formula (as a String), using a CSV file that contains elements and their atomic masses. My code for this particular problem is this: I have another method “fileReader” that takes the data from the mile and returns a map with the elements as the key and

## Filter distinct groups and get average of String values parsing as Integer or Double

I have a POJO like below: And a List like below: Now I am trying to filter and group all the employees by department and need to get the highest spending department. If salary is of type Double (say) I can do it like below: And I get the expected output: But I am clueless what to do if I

## Trying to create a calculator for Newton’s Square Root without using built-in things for school. I have it down but the math is a little off

I will be able to accept an answer in 6 minutes. For now going to state that my answer has successfully been solved by Elliott Frisch. He provided a solution to fix the problem I ran into. When attempting to do the “Equation” it correctly performs the action but seems to be off. Off being that it doesn’t really display

## Comparison of Double Constants

I researched this a lot and I know something about precision errors in the doubles; however I couldnt find the answer. My question is: is it always safe to compare double constants? What do I mean by that is, just reading the double from a string or creating in the source code. No operation (adding, subtracting etc.) will be done

## How can I intentionally create random floating point / decimal precision errors in java?

My goal is to generate random numbers that all have decimal precision errors. Here are some examples of types of numbers I would like to generate: 1.8181818723678589 1.2727272510528564 0….

## ‘OptionalDouble.getAsDouble()’ without ‘isPresent()’ check

I’ve seen a bunch of solutions for this question but no matter what I try, IDEA still reports an error. Consider the following block: double testDouble= customClass.stream() .mapToDouble(…

## Game Of Life game: Check 2D array 8 closest surroundings; ArrayIndexOutOfBoundsException issue

I have encountered this problem and i couldn’t find the solution. There is a 2D array with only zeros and ones in it (the size of the array doesnt really matter, i worked with 10×10). Zero means dead …

## How to implement Body Mass Index (BMI)in Java

My problem is how can I implement without the Scanner method and with Math.round and Math.pow? Here is my code: import java.util.Scanner; public class BMI{ public static void main(String …

## Trying to sort a Double Collection

I am trying to sort a Collection. I cant seem to get my code to work with what I have found online. Collection: [104.131119, 104.188937, 93.174548, 100.533096, 97.902247, 98.608619, 93.380054, 106….