Java Programming
Java Programming
9th Edition
ISBN: 9780357616635
Author: Joyce Farrell
Publisher: CENGAGE L
Expert Solution & Answer
Book Icon
Chapter 3, Problem 7PE

Explanation of Solution

Program code:

InchConversion.java

//import the packages

import java.util.Scanner;

//define a class InchConversion

public class InchConversion

{

//define main() method

public static void main(String[] args)

{

//create the object of Scanner class

Scanner in = new Scanner(System.in);

//prompt the user to enter the inches

System.out.print("Enter number of inches: ");

//scan for the input

int inches = in.nextInt();

//call the static methods

convertToFeet(inches);

convertToYards(inches);

}

//define the method convertToFeet()

public static void convertToFeet(int inches)

{

//convert the inches to feets and print on the screen

System.out.println(inches + " inches is " + (inches/12.0) + " feets.");

}

//define the method convertToYards()

public static void convertToYards(int inches)

{

//convert the inches to yards and print on the screen

System.out...

Blurred answer
Students have asked these similar questions
USE JAVA IDE Create a class that has three methods. One method is to input three numbers. The second method will return the largest number between the three numbers. The third method will return the smallest number between the three numbers. Since the largest and smallest number are both returned values, display these values in the main method.
Starting Out with Java From Control Structures through Objects 6th Edition
Travel Tickets Company sells tickets for airlines, tours, and other travel-related services. Because ticket agents frequently mistype long ticket numbers, Travel Tickets has asked you to write an application that indicates invalid ticket number entries. The class prompts a ticket agent to enter a six-digit ticket number. Ticket numbers are designed so that if you drop the last digit of the number, then divide the number by 7, the remainder of the division will be identical to the last dropped digit. Accept the ticket number from the agent and verify whether it is a valid number. Test the application with the following ticket numbers: . 123454; the comparison should evaluate to true . 147103; the comparison should evaluate to true . 154123; the comparison should evaluate to false Save the program as TicketNumber.java.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    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
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT