Hola a todos estoy teniendo un problema con este programa quisiera saber si alguien me puede ayudar a resolver este problema? El programa tiene 2 clases y la tercera tiene el main. Muchas gracias.
import java.util.Scanner; // needed for Scanner class
import java.text.DecimalFormat; // needed for DecimalFormat class
public class CarpetTester
{
public static void main(String[] arg)
{
double length;
double width;
double price;
Scanner keyboard = new Scanner(System.in);
DecimalFormat df = new DecimalFormat("$#,##0.00");
System.out.print("Please enter the length of the room: ");
length = keyboard.nextDouble();
System.out.print("Please enter the width of the room: ");
width = keyboard.nextDouble();
System.out.print("Please enter the price per squart foot: ");
price = keyboard.nextDouble();
RoomDimensio dimension = new RoomDimensio(length, width);
RoomCarpet carpet = new RoomCarpet(dimension, price);
System.out.println("The total cost of the carpet is: " + df.format(carpet.getTotalCost() ) );
}
}
public class RoomDimensio
{
private double length;
private double width;
public RoomDimensio(double len, double wid)
{
len = length;
wid = width;
}
public double getArea()
{
double area = (length * width);
return area;
}
public String toString()
{
return "Length: " + length + "width: " + width +" Area: " + getArea();
}
}
public class RoomCarpet
{
private RoomDimensio dimension;
private double carpetCost;
public RoomCarpet(RoomDimensio dim, double cost)
{
dim = dimension;
cost = carpetCost;
}
public double getTotalCost()
{
double finalCost = (carpetCost * dimension.getArea());
return finalCost;
}
public String toString()
{
return "Total cost: " + getTotalCost();
}
}