(no title) (original) (raw)
Thanks for all your help on the last question! Now, I have a new assignment I would like to verify if I did correctly. I probably lack self confidence, or something.
Here's the exact instructions for the assignment
"As an individual exercise, write a program named InchesToCentimeters that includes a static method to convert inches to centimeters, printing the result on a line. Be sure to print the input value, the output value, and the units for each. Then, in the main method of your program, invoke your conversion method for the values 12, 1, and 2.0. The result should be that your program will print three lines total. Save your program in a file named InchesToCentimeters.java "
My code:
public class InchesToCentimeters {
private static void printCENTIMETERS(double givenInches) {
final double CM_PER_INCH = 2.54;
// Perform conversion: givenInches are the inches we are given to compute
//
double resultCenti = (givenInches * CM_PER_INCH);
// display result by *invoking* the "println" method
// of the variable "System.out":
//
System.out.println () ;
System.out.print ( + givenInches + " inches converts to ");
System.out.print ( + resultCenti + " centimeters");
}
// main(): application entry point
//
public static void main (String[] args) {
// *Invoke* method to calculate & print centimeters,
// passing *arguments* 12, 1, and 2.0 inches:
//
printCENTIMETERS (12) ;
printCENTIMETERS (1) ;
printCENTIMETERS (2.0) ;
}
}
Is all of that okay? Does it address all the requirements of the assignment? Thanks so much for your help!