Question

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”.

Homework Answers

Answer #1
import java.util.Scanner;

public class MillimetersToMetersCM {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int millimeters, meters, centimeters, n;

        System.out.print("Enter number of millimeters: ");
        millimeters = scan.nextInt();

        n = millimeters;

        meters = millimeters/1000;

        millimeters = millimeters % 1000;

        centimeters = millimeters / 10;

        millimeters = millimeters % 10;

        System.out.println(n+" millimeters = "+meters+" meters "+centimeters+" centimeters and "+millimeters+" millimeters");
    }
}

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 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)
In Java. Write a program that reads-in a times table-number. The program, using this table-number will...
In Java. Write a program that reads-in a times table-number. The program, using this table-number will produce the following report (as shown). The first item in the report is a number with starting value 1. Second column is the word “ X ” (representing the times symbol). Third column is the table-number (itself). Following is an equal sign “ = “ (representing a result). Last column is the result of the operation for that line or row which is the...
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...
In JAVA the question will change as the quiz goes on (You don't have to do...
In JAVA the question will change as the quiz goes on (You don't have to do the whole project I just need help with the bolded portion of the question) Design an interactive multiple-choice quiz app on your choice of subject. Your quiz must consist of at least 10 questions. You must have to use nested layouts and customize the buttons used in your app. The app must also display the user’s progress throughout the quiz, showing the question number...
1) How many significant figure are in the number 0.00150? Group of answer Choices: 5 2...
1) How many significant figure are in the number 0.00150? Group of answer Choices: 5 2 3 4 2) If the calculation 12.1202 - 0.10 is performed, what is the answer to the correct number of significant figures? Group of answer choices: 12.0202 12.02 12 12.0 3) Which measurement does not represent the same length as the others? Group of answer choices: 0.01 kilometers 10 meters 1000 centimeters 100 millimeters 4) Lead has a density of 11.34 g/cm3. If one...
The temperature at a point (x, y, z) is given by T(x, y, z) = 400e−x2...
The temperature at a point (x, y, z) is given by T(x, y, z) = 400e−x2 − 5y2 − 9z2 where T is measured in °C and x, y, z in meters. (a) Find the rate of change of temperature at the point P(2, −1, 2) in the direction towards the point (3, −5, 6). °C/m (b) In which direction does the temperature increase fastest at P? (c) Find the maximum rate of increase at P.
The temperature at a point (x, y, z) is given by T(x, y, z) = 100e^(−x^2...
The temperature at a point (x, y, z) is given by T(x, y, z) = 100e^(−x^2 − 3y^2 − 9z^2) where T is measured in °C and x, y, z in meters. (a) Find the rate of change of temperature at the point P(2, −1, 2) in the direction towards the point (5, −2, 3). (b) In which direction does the temperature increase fastest at P? (c) Find the maximum rate of increase at P.
Java code Problem 1. Create a Point class to hold x and y values for a...
Java code Problem 1. Create a Point class to hold x and y values for a point. Create methods show(), add() and subtract() to display the Point x and y values, and add and subtract point coordinates. Tip: Keep x and y separate in the calculation. Create another class Shape, which will form the basis of a set of shapes. The Shape class will contain default functions to calculate area and circumference of the shape, and provide the coordinates (Points)...
Design a Java class named Polygon that contains:  A private int data field named numSides...
Design a Java class named Polygon that contains:  A private int data field named numSides that defines the number of sides of the polygon. The default value should be 4.  A private double data field named sideLength that defines the length of each side. The default value should be 5.0.  A private double data field named xCoord that defines the x-coordinate of the center of the polygon. The default value should be 0.0.  A private double...
JAVA ASSIGNMENT 1. Write program that opens the file and process its contents. Each lines in...
JAVA ASSIGNMENT 1. Write program that opens the file and process its contents. Each lines in the file contains seven numbers,which are the sales number for one week. The numbers are separated by comma.The following line is an example from the file 2541.36,2965.88,1965.32,1845.23,7021.11,9652.74,1469.36. The program should display the following: . The total sales for each week . The average daily sales for each week . The total sales for all of the weeks .The average weekly sales .The week number...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT