I'm working on a school project, beginner stuff. I need to output the data with 2 decimals. I've tried several variations of
printf("%4.2f" + variable)
But it seems when I use more than one variable it craps out or wont compile. Thoughts?
public class Conference4 {
public static void main(String[] args) {
System.out.println("Feet\t\tMeters\tFeet\tMeters");
System.out.println("---------------------------------------------");
double foot = 1; double meter = 20;
for (int i = 1; i <= 10; foot++, meter += 5, i++) {
System.out.println(foot + "\t\t" + footToMeter(foot) + "\t|\t" + meter + "\t\t" + meterToFoot(meter));
}
}
public static double footToMeter(double foot) {
return (3.05 * foot);
}
public static double meterToFoot(double meter) {
return (meter / .305);
}
}