/**
 * Format a table of temperature conversions, using String format 
 * and System.out.printf
 *
 * @author CSCI209
 */
public class TemperatureTable {

    public static void main(String[] args) {
        String headingFormat = "%10s %10s %10s";
    
        String headings = String.format(headingFormat, "Temp C", "Temp F", "Temp K");
        String lines = String.format(headingFormat, "------", "------", "------");
    
        System.out.println(headings);
        System.out.println(lines);
    
        // Note: it would be better to have the values calculated rather than 
        // hardcoded, but our focus right now is on formatting.
        double[] temps = {-459.7, -273.1, 0.0};
    
        String tempFormat = "%10.1f %10.1f %10.1f";
    
        // Using String.format
        System.out.println(String.format(tempFormat, temps[0], temps[1], temps[2]));
    
        // Alternatively: using System.out.printf
        // Need to add the \n because printf doesn't automatically add that.
        System.out.printf(tempFormat + "\n", temps[0], temps[1], temps[2]);
    
        double[] temps2 = {0.0, -17.8, 255.4};
    
        System.out.println(String.format(tempFormat, temps2[0], temps2[1], temps2[2]));
    
    
        double[] temps3 = { 32.0, 0.0, 273.1};
    
        System.out.println(String.format(tempFormat, temps3[0], temps3[1], temps3[2]));
    
        // Including \n in the template string
        tempFormat = tempFormat + "\n";
        System.out.printf(tempFormat, temps3[0], temps3[1], temps3[2]);
    }
    
}
