Question

Using Java, given 2 numbers which are the measurement of a distance in feet and inches,...

Using Java, given 2 numbers which are the measurement of a distance in feet and inches, for example 3 feet 7 inches. Change the measurement to meters and centimeters, and display message “? feet ? inches = ? meters and ? centimeters”. The ? should be replaced by real numbers. (1 inch = 2.54 centimeter, 1 foot = 12 inches)

Homework Answers

Answer #1
import java.util.Scanner;

public class FeetInchesToMeters {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter number of feet: ");
        int feet = in.nextInt();
        System.out.print("Enter number of inches: ");
        int inches = in.nextInt();

        int totalInches = 12 * feet + inches;
        double totalCM = 2.54 * totalInches;
        int meters = (int) (totalCM / 100);
        double remainingCM = totalCM - (meters * 100);
        System.out.println(feet + " feet " + inches + " inches = " + meters + " meters and " + remainingCM + " centimeters");
    }
}

Know the answer?
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
Similar Questions
Using Java, given a number which is the measurement of a distance in millimeter, change the...
Using Java, given a number which is the measurement of a distance in millimeter, change the representation of this number to the format of: x meters y centimeters and z millimeters. For example, if the number is 12345 millimeters, display the message: “12345 millimeters = 12 meters 34 centimeters and 5 millimeters”.
Write a java program to display a given range of integer numbers (0 to 9) in...
Write a java program to display a given range of integer numbers (0 to 9) in the following order: Example : given (5 to 9), the program displays 56789 67895 78956 89567 95678 The first line displays the min to max range. Each line that follows should display the next higher number except when it hits the maximum number. In that situation, the line wraps back to the minimum sequence. For this problem write a static method to do the...
3. The following is the formula to convert a Celsius degree to Fahrenheit degree: Fahrenheit =...
3. The following is the formula to convert a Celsius degree to Fahrenheit degree: Fahrenheit = (9/5) Celsius + 32 Write a program to prompt user to enter a Celsius degree, convert it to Fahrenheit and display Given an integer value which is the measurement of weight in ounce. Convert it to the format of: x pounds and y ounces. For example, if the given number is 100 ounces, it will be represented as 6 pounds and 4 ounces after...
Using Java. The distance a vehicle travels can be calculated as follows: Distance = Speed *...
Using Java. The distance a vehicle travels can be calculated as follows: Distance = Speed * Time For example, if a train travels 40 miles-per-hour for three hours, the distance traveled is 120 miles. Write a program that asks for the speed of a vehicle (in miles-per-hour) and the number of hours it has traveled. Both values are assumed to be integers. It should use a loop to display the distance a vehicle has traveled for each hour of a...
Java please. Given a sequence of unsorted numbers, determine how badly out of order they are....
Java please. Given a sequence of unsorted numbers, determine how badly out of order they are. Write a program that, for any given sequence of unique natural numbers, will compute the 'distance' between that original ordering and the same set of numbers sorted in ascending order. The distance should be computed by calculating how far displaced each number is in the original ordering from its correct location in the sorted list and summing those results. For instance, given the list...
1) Write a java programming using a while loop where you will add numbers and when...
1) Write a java programming using a while loop where you will add numbers and when you press number 0 it will add all your numbers and display the results. Use Scanner object. Steps: 1) Declare variables integer called sum which is equal to zero   2) Declare Scanner object   3) Declare while condition where is true   4) Inside of that condition prompt the user to enter the numbers   5) Declare variable integer called number and input the number statement   6)...
Writ a program using java. Depending on the size of the room and the amount of...
Writ a program using java. Depending on the size of the room and the amount of shade that the room has, different sizes of air conditioning units must be used in order to be able to properly cool the room. The unit of measure for the amount of cooling that an air conditioner unit can provide is the BTU (British Thermal Unit) per hour. Code a program that will calculate the correct size of air conditioner for a specific room...
JAVA Problem 1: Summing It Up Write a program, which takes two distinct integers separated by...
JAVA Problem 1: Summing It Up Write a program, which takes two distinct integers separated by space as input and prints the sum of all the integers between them, including the two given numbers. Note that the numbers can appear in either order. You may assume that both numbers are between –10, 000 and 10, 000. For example, if the input is as follows: 10 4 the output should be 49, since 10+9+8+7+6+5+4=49. Similarly, if the input is -3 10...
2). Question with methods use scanner (Using Java): You are going to invest the amount, then...
2). Question with methods use scanner (Using Java): You are going to invest the amount, then you going to compute that amount with annual interest rate. 1) Prompt the user to enter student id, student name, student major 2) Declare variables consistent with names that you are prompting and relate them to the scanner 3) Declare the amount invested in college, prompt the user to ask for amount and declare variable and scanner to input 4) Declare the annual interest...
Activity 2: Applications of the Derivatives To make a phrase/words, solve the 18 application of derivatives...
Activity 2: Applications of the Derivatives To make a phrase/words, solve the 18 application of derivatives below. Then replace each numbered blank with the letter corresponding to the answer for that problem. Show all solutions on the answers given below. "__ __ __    __ __ __ __ __ __ ,    __ __ __    __ __    __ __ __ __ ."                                                                                                                                  1-2. A certain calculus student hit Mr. Pleacher in the head with a snowball. If the snowball is melting...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT