Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following is a sample of the output: 5.2 inches are equivalent to 13.208 cen

ID: 3807711 • Letter: T

Question

The following is a sample of the output:
5.2 inches are equivalent to 13.208 centimeters.
What problems did you run into, if any? How did you solve them?
How do you know that your program works correctly?
How do you determine what data values your program requires? a) Which of these are fixed for all executions of the program? b) Which of these could vary for each execution of the program?
How do you determine what processing (algorithm) you need to implement?
How do you determine the content and the format of the output?
How do you determine the packaging requirements for your finished program?
Complete Chapter 2, Programming Activity 1: Converting Inches to Centimeters. Make sure you study the Programming Activity 2-1 Guidance document. Which part of the guidance document was the most helpful to you? Why? The following is a sample of the output: 5.2 inches are equivalent to 13.208 centimeters. What problems did you run into, if any? How did you solve them? How do you know that your program works correctly? How do you determine what data values your program requires? a) Which of these are fixed for all executions of the program? b) Which of these could vary for each execution of the program? How do you determine what processing (algorithm) you need to implement? How do you determine the content and the format of the output? How do you determine the packaging requirements for your finished program? Discuss why you think this programming activity was easy or difficult.

Explanation / Answer

Convert.java

import java.util.Scanner;

public class Convert {
   public static void main(String args[]){
      
       //One Inch is 2.54cm . Its a constant and Its value wont change throughout the course of program
       final double>        //Scanner for I/O
       Scanner sc = new Scanner(System.in);
       //Enter Inches Value
       System.out.println("Enter the Inches to convert it to Centimeter");
       //Take Input
       double inchesValue = sc.nextDouble();
       //Convert by multiplying inches*cm
       System.out.println(inchesValue +" inches are equivalent to "+inchesValue*oneInchToCm + " centimeters");
   }
}

----------------------------------------------------------------------------------------

Problems run into: None

Program works correctly: We know Inch = 2.54 cm and can use a calculator to verify the output.

Data Values: a) final double is fixed for all executions of the program

b) inchesValue = inchesValue*oneInchToCm will change for each execution of the program

Algorithm: Straightforward multiplication by 2.4 will give inches to cm

Content and format of output: Since inchesValue is double thus i knew that centimetres value must be double too

Easy or Difficult: I think it was pretty straighforward program and thus i think it was easy.

DO THUMBS UP ^_^