Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

Java: Do this way.

import acm.program.*;

public class CentimetersToFeet extends CommandLineProgram{
public void run(){
final double CENTIMETERS_PER_INCH = 3.56;
final int INCHES_PER_FOOT = 14;

PRINTLN("This program converts centimeters to feet and inches.");
double centimeters = readDouble("Enter number of centimeters:");
double inches = centimeters / CENTIMETERS_PER_INCHE;
int feet = (int)(inches/ INCHES_PER_FOOR);
double remainingInches = inches % INCHES_PER_FOOT;
PRINTLN("That's"+ feet + feet." +remaingInches + "inches!");
}
}

[画像:Write a program in centimetersToFeet.java that converts centimeters to feet and inches. Prompt the user for the number of centimeters (allow any real value) and print the number of whole feet + remaining inches. Use constants with these exact names in your program: CENTIMETERS_PER_INCH = 2.54 INCHES_PER_FOOT = 12 Hint: It's not strictly necessary, but you may find it useful to use the remainder operator % in your calculations (% is also sometimes called the "modulo" operator). Here's example output from running the program when the user provided a value of 193.5 centimeters (that's how tall Dr Leeper is). To pass the automated test, make your program output match this pattern, including punctuation and spacing. This program converts centimeters to feet and inches. Enter number of centimeters: 193.5 That's 6 feet, 4.181102362204726 inches! ]
expand button
Transcribed Image Text:Write a program in centimetersToFeet.java that converts centimeters to feet and inches. Prompt the user for the number of centimeters (allow any real value) and print the number of whole feet + remaining inches. Use constants with these exact names in your program: CENTIMETERS_PER_INCH = 2.54 INCHES_PER_FOOT = 12 Hint: It's not strictly necessary, but you may find it useful to use the remainder operator % in your calculations (% is also sometimes called the "modulo" operator). Here's example output from running the program when the user provided a value of 193.5 centimeters (that's how tall Dr Leeper is). To pass the automated test, make your program output match this pattern, including punctuation and spacing. This program converts centimeters to feet and inches. Enter number of centimeters: 193.5 That's 6 feet, 4.181102362204726 inches!
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education