import java.io.PrintStream; import java.util.Scanner; public class Carpet { public static void main(String[] args) { PrintStream output = System.out; Scanner input = new Scanner(System.in); output.print("Enter the diameter of the room : "); double diameter = input.nextDouble(); output.print("Enter the price per square meter : "); double price = input.nextDouble(); final int CENTS_PER_DOLLAR = 100; long priceInCents = Math.round(price * CENTS_PER_DOLLAR); double radius = 0.5 * diameter; double area = Math.PI * radius * radius; long areaRoundedUp = (long) Math.ceil(area); long costInCents = priceInCents * areaRoundedUp; long dollars = costInCents / CENTS_PER_DOLLAR; long cents = costInCents % CENTS_PER_DOLLAR; output.printf("Total cost is %d dollars and %d cents%n", dollars, cents); } }