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”.
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...
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)...
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...
is there anything wrong with the solution. the question are from java course Write a main...
is there anything wrong with the solution. the question are from java course Write a main method that will request the user to enter Strings using a JOptionPane input dialog. The method should continue accepting strings until the user types “STOP”.       Then, using a JOptionPane message dialog, tell the user how many of the strings begin and end with a digit. Answer: import javax.swing.*; public class IsAllLetters {     public static void main(String[] args) {         String input;         int count =...
I am trying to make a program in C# and was wondering how it could be...
I am trying to make a program in C# and was wondering how it could be done based on the given instructions. Here is the code that i have so far... namespace Conversions { partial class Form1 { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if...
Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop...
Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop to print the numbers from 42 - 56. Uses a for loop to print the numbers from 87 - 95. Asks the user for 2 numbers. Uses a loop to print all numbers between the given numbers, inclusive. Note: Consider that your user's second number can be lower! (see example below) Note: Also consider that your user might give you two of the same...
please can you make it simple. For example using scanner or hard coding when it is...
please can you make it simple. For example using scanner or hard coding when it is a good idea instead of arrays and that stuff.Please just make one program (or class) and explain step by step. Also it was given to me a txt.htm 1.- Write a client program and a server program to implement the following simplified HTTP protocol based on TCP service. Please make sure your program supports multiple clients. The webpage file CS3700.htm is provided. You may...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as possible: What is a checked exception, and what is an unchecked exception? What is NullPointerException? Which of the following statements (if any) will throw an exception? If no exception is thrown, what is the output? 1: System.out.println( 1 / 0 ); 2: System.out.println( 1.0 / 0 ); Point out the problem in the following code. Does the code throw any exceptions? 1: long value...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item = 0; 4. while (count < 4) { 5.      cout << "Enter item cost: "; 6.      cin >> item; 7.      item_total += item; 8.      ++count; 9. } 10. int average_cost = round(item_total / count); 11. cout << "Total cost: " << item_total << "\nAverage cost: " << average_cost; (Refer to Code Example 8-1.) If the user enters 5, 10, and 15 at the prompts, the output is: Total...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT