This should be simple for you guys. I am writing a simple program. The
correct answer is 630, however java comes up with 626.4. I assume this
is a rounding issue because I used the wrong variable type, but after
a couple hours on this thing I have no idea. Anyone have any
suggestions?
public class yards
{
public static void main(String[] args)
{
byte length=25;
byte width=42;
int product= length * width;
float totalsquareyards=product / 9;
double cost= totalsquareyards * 5.4f;
System.out.println("");
System.out.print("The carpeting is " + length);
System.out.println(" feet long.");
System.out.println("");
System.out.print("The carpeting is " + width);
System.out.println(" feet wide.");
System.out.println("");
System.out.print("It will cost $" + cost);
System.out.println(" to carpet the room");
System.out.println("");
}
}
Thanks!
--
Luke M. P. Vandervort
Linux, because rebooting is for adding new hardware ...
--
You received this message because you are subscribed to the Google Groups "The
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/javaposse?hl=en.