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 vhen 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.181102362284726 inches!

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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!
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Top down approach design
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education