semisonic9
Gawd
- Joined
- May 2, 2005
- Messages
- 769
I'm trying to figure out how to limit a float output to two points past the decimal.
And I need the acreage only to two decimal places. Having a devil of a time trying to figure out how to make that happen.
I also need to know how to have it round up or down, as appropriate, for situations handling money.
Example Code said:import java.util.Scanner;
public class Land {
public static void main(String[] args) {
int length, width;
float acreage;
Scanner keyboard = new Scanner(System.in);
System.out.println("Please enter the length, in feet, of the length of a piece of land.");
length = keyboard.nextInt();
System.out.println("Please enter the length, in feet, of the width of a piece of land.");
width = keyboard.nextInt();
acreage = (length * width) / 43560;
System.out.println("Your acreage is " + acreage);
}
}
And I need the acreage only to two decimal places. Having a devil of a time trying to figure out how to make that happen.
I also need to know how to have it round up or down, as appropriate, for situations handling money.