Question

8. Use a for loop to create a table that converts inches to feet. Java Programming

8. Use a for loop to create a table that converts inches to feet. Java Programming

0 0
Add a comment Improve this question Transcribed image text
Answer #1

As no specific programming language is given, I answered this in JAVA

Java Code:

import java.text.DecimalFormat;

public class Tester3 {

    public static void main(String args[]){

    //Using DecimalFormat to round the output upto two decimal places

    DecimalFormat df2 = new DecimalFormat("##.##");

    System.out.println("Inch\tFeet");

    //For loop that prints the table of inches to Feet

    for (int inch=0; inch<=24; inch++){

            //inch = feet/12

            double feet=(double)inch/12;

            System.out.println(inch+"\t"+df2.format(feet));

    }

    }

}

Output:

Add a comment
Know the answer?
Add Answer to:
8. Use a for loop to create a table that converts inches to feet. Java Programming
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use a for-loop to solve the following problems, and then repeat using a while-loop. Create a...

    Use a for-loop to solve the following problems, and then repeat using a while-loop. Create a vector containing values of a measurement in inches spanning from 0 to 24 inches. Use these values to create a conversion table from inches to feet and display the result.

  • Write a Python function that converts a measurement in d feet and e inches to a...

    Write a Python function that converts a measurement in d feet and e inches to a measurement in inches. Hint: 12 inches 1 ft. Hence 10 ft and 4 inches is equivalent to 124 inches. In : def inches (d,e) # YOUR CODE HERE inches (10,4)--124 In [11 inches(1,4)--16

  • In Java: Create an array of Integers with 10 elements, loop (use a for loop) through...

    In Java: Create an array of Integers with 10 elements, loop (use a for loop) through the array of integers printing their values to the screen. Create an array of Strings with 10 elements, loop (use a for loop) through the array of Strings printing their values to the screen. Finally, create an ArrayList of Integers. Use the loop from part 1 above and add each integer as you print it to the ArrayList as well, then start a final...

  • Python Programming 4th Edition: Write a program that asks the user for the number of feet....

    Python Programming 4th Edition: Write a program that asks the user for the number of feet. The program converts those feet to inches by using the formula ’12 * feet’. Hint: Define main () program Get the number of feet from the user Define variables Call a function feet_to_inches(feet) The function receives the number of feet and returns the number of inches in that many feet. The output should look like as follows: Enter the number of feet: If the...

  • Write a program in Java that converts the following do-while loop block to: for loop Write,...

    Write a program in Java that converts the following do-while loop block to: for loop Write, compile and run below program segment. Make sure to click on the Output Window to input the number. Evaluate the program. Take notes and comment of below program segments of your observations. int x; Scanner input = new Scanner(System.in);       x = input.nextInt();       do{             System.out.printf(“%d\n”, x * 2);             x++;       } while(x < 100);

  • qbasic is the programming language Chapter 8 Do Programming Exercise 8-3 om page 414. Create a...

    qbasic is the programming language Chapter 8 Do Programming Exercise 8-3 om page 414. Create a string array to hold the months of the year. Call it anything you want to just make sure it's a string array is at the end of the name, e.g. months). Create a DATA statement that holds the month names: DATA "jan","Feb", "Mar" etc. Next you'll need a FOR loop to READ the DATA into the array, Call a SUB to get the rainfall...

  • Using Python programming, create a 2-by-3 list, then use a nested loop to: 1) Set each...

    Using Python programming, create a 2-by-3 list, then use a nested loop to: 1) Set each element's value to an integer indicating the order in which it was processed by the nested loop (1, 2, 3, 4, 5, 6). 2) Display the elements in tabular format. Use the column indices as headings across the top, and the row indices to the left of each row.

  • question in java programming : Suppose that you are an instructor and want to create a...

    question in java programming : Suppose that you are an instructor and want to create a table that contains a list of students and their marks, like the following: Ahmad 80 7 Khalid Mohammed 91 Adil 66 74 Saeed Yousef 78 Omar 85 Salim Write a program that will store this information in a map and print all its members.

  • In Java Write a program the takes in a number and converts it to binary. Use...

    In Java Write a program the takes in a number and converts it to binary. Use an OOP class approach using class and objects

  • Please create a java program and use a do/while loop to check for the correct password...

    Please create a java program and use a do/while loop to check for the correct password entered by the student. The password should be your initials and 2020Mar23. For example, my password would be "TJC2020Mar23". If the user has not entered the correct password after 3 attempts, they should receive a message to that effect and they should not be allowed any further attempts.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT