{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}


FormattedFeetInch - f inches = feet INCHES_IN_FOOT i...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// File: FormattedFeetInch.java // Author: Amber Settle // Course: CSC 211 // Purpose: A program to demonstrate formatting output using // the printf method / import java.util.Scanner; i public class FormattedFeetInch { public static void main(String[] args) { final double INCHES_IN_FOOT = 12.0; f double feet, inches; int wholeInches; i Scanner inputNum = new Scanner(System.in); S System.out.print("Enter a number in feet: "); feet = inputNum.nextDouble();
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: f inches = feet * INCHES_IN_FOOT; i System.out.println(); S System.out.printf("%.2f feet is %10.2f inches\n\n", feet, inches); S System.out.print("Now, enter a whole number in inches: "); wholeInches = inputNum.nextInt(); w feet = wholeInches / INCHES_IN_FOOT; f System.out.println(); S System.out.printf("%2$d inches is %1$.6f feet\n", feet, wholeInches); } }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online