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...
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...
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.
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)...
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.
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...
The temperature at a point (x,y,z) is given by T(x,y,z)=200e−x2−y2/4−z2/9, where Tis measured in degrees celcius...
The temperature at a point (x,y,z) is given by T(x,y,z)=200e−x2−y2/4−z2/9, where Tis measured in degrees celcius and x,y, and z in meters. There are lots of places to make silly errors in this problem; just try to keep track of what needs to be a unit vector. Find the rate of change of the temperature at the point (0, 1, -2) in the direction toward the point (-1, -2, 5). In which direction (unit vector) does the temperature increase the...
Simplify the following Boolean functions, using K-maps. Find all the prime implicants, and determine which are...
Simplify the following Boolean functions, using K-maps. Find all the prime implicants, and determine which are essential: (a) F (w, x, y, z) = ? (1, 4, 5, 6, 12, 14, 15) (b) F (A, B, C, D) = ? (2, 3, 6, 7, 12, 13, 14) (c) F (w, x, y, z) = ? (1, 3, 4, 5, 6, 7, 9, 11, 13, 15)
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT