Change the line
System.out.println(Math.round(nr1 / nr2*10.0)/10.0);
To the line
System.out.println(Math.round(nr1 / ((double)nr2)*10.0)/10.0);
Because when you divide two integers, the answer is always an integer which is always rounder down ((int)2.9 = 2 and (int)3.1 = 3). cast into doubles and then divide in order to get the right answer.
Let's look at the following code:
int a = 10;
int b = 3;
System.out.println(a/b);
This will print 3, it will not print 3.3333333... that is because when dividing integers the result is always an integer and always rounded down. There are several ways to solve this
int a = 10;
double b = 3;
System.out.println(a/b);
This will print 3.3333333... because we are no longer dividing 2 integers, one of the variables is a double and therefor the result will be a double
Other ways:
Cast into a double:
int a = 10;
int b = 3;
System.out.println((double)a/b);
Multiplying an integer with a double will result in a double and therefor this will also work
int a = 10;
int b = 3;
System.out.println(1.0*a/b);
Notice that this will not work
int a = 10;
int b = 3;
System.out.println(a/b * 1.0);
This will not work because the division will be calculated before the multiplication and you will get the result 3.0 .