Java Programming (MindTap Course List)
Java Programming (MindTap Course List)
8th Edition
ISBN: 9781285856919
Author: Joyce Farrell
Publisher: Cengage Learning
Question
Book Icon
Chapter 3, Problem 7PE
Program Plan Intro

Metric Conversion

Program Plan:

Define the class “MetricConversion”.

  • Define the main method.
    • Declare the required variables.
    • Get the values from the user using the scanner class.
    • Call the method “convertToCentimeters()”.
    • Call the method “convertToLiters()”.
  • Definition of method “convertToCentimeters()”.
    • Declare the variable “cm”.
    • Assign “2.54” to “CENT_FACTOR”.
    • Calculate and print the values in centimeters.
  • Definition of method “convertToLiters ()”.
    • Declare the variable “liters”.
    • Assign “3.784” to “GALLON_FACTOR”.
    • Calculate and print the values in liters.

Blurred answer
Students have asked these similar questions
// Question 4: // Declare an integer variable named "variables with an initial value of 10. // Write a method named "SetToOne" that takes one out parameter. // The method should set the out parameter to 1. // Call the method SetToOne passing variables in the btnQ4 click method. // Display the variable variables in the lblQ4. private void btn04_Click(object sender, EventArgs e) {
Modify the Percentages application whose main() method holds two double variables. Assign values to the variables. Pass both variables to a method named computePercent() that displays the two values and the value of the first number as a percentage of the second one. For example, if the numbers are 2.0 and 5.0, the method should display a statement similar to “2.0 is 40.0 percent of 5.0.” Then call the method a second time, passing the values in reverse order. For testing use the values 2.0 and 5.0. An example of the program is shown below: 2.0 is 40.0 percent of 5.0 5.0 is 250.0 percent of 2.0
// Question 4: // Declare an integer variable named "variables with an initial value of 10. // Write a method named "SetToOne" that takes one out parameter. // The method should set the out parameter to 1. // Call the method SetToOne passing variables in the btngs click method. // Display the variable variables in the lblQ4. private void btn04_Click(object sender, EventArgs e) {
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning