1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Andreas93 [3]
4 years ago
9

Write a program that includes functions to calculate feet to inches, inches to feet, feet to yards, and yards to feet. Then, acc

ept input from the user to test these functions.

Computers and Technology
2 answers:
RoseWind [281]4 years ago
7 0

Answer:

The program with all the functions implemented in Java programming language is given in the explanation section

Explanation:

import java.util.Scanner;

public class num11 {

   public static double feetToInches(double feet){

       return feet*12;

   }

   public static double inchesToFeet(double inches){

       return inches/12;

   }

   public static double feetToYard(double feet){

       return feet/3;

   }

   public static double yardToFeet(double yard){

       return yard*3;

   }

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter length in feet");

       double lenFeet = in.nextDouble();

       System.out.println("The equivalent in Inches is "+feetToInches(lenFeet));

       System.out.println("The equivalent in yard is "+feetToYard(lenFeet));

       System.out.println("enter value in Inches");

       double lenInches = in.nextDouble();

       System.out.println("The equivalent feet is "+inchesToFeet(lenInches));

       System.out.println("enter value in Yards");

       double lenYard = in.nextDouble();

       System.out.println("The equivalent feet is "+yardToFeet(lenYard));

   }

}

Montano1993 [528]4 years ago
6 0

Explanation:

One line simple functions are created. The four functions ft2inc, inc2ft, ft2yd, and yd2ft convert feet to inches, inches to feet, feet to yards, and yards to feet respectively. Then in the test code, input is taken from the user and each function is called one by one. eval is used to ensure numeric input from the user. The program is tested multiple times and it returns correct results.

Python Functions:

def ft2inc(ft):

   return print("Feet to Inches: ",ft*12)

def inc2ft(inc):

   return print("Inches to Feet: ",inc/12)

def ft2yd(ft):

   return print("Feet to Yards: ",ft/3)

def yd2ft(yd):

   return print("Yards to Feet: ",yd*3)

Test Code:

ft=eval(input("Conversion Feet to Inches: "))

ft2inc(ft)

inc=eval(input("Conversion Inches to Feet: "))

inc2ft(inc)

ft=eval(input("Conversion Feet to Yards: "))

ft2yd(ft)

yd=eval(input("Conversion Yards to Feet: "))

yd2ft(yd)

Output:

Conversion Feet to Inches: 2

Feet to Inches: 24

Conversion Inches to Feet: 48

Inches to Feet: 4.0

Conversion Feet to Yards: 9

Feet to Yards: 3.0

Conversion Yards to Feet: 12

Yards to Feet: 36

You might be interested in
You want to add a new Product and Services entry to your client's QuickBooks Online company. The service is installation of a se
Kisachek [45]

Answer:  

The correct answer is Option 3: "Select Service"  

You have to select "Service" in the Second Step.  

Only after that, you'll be able to name the Service in the following step.  

Other options are invalid for a given question.

6 0
3 years ago
Frank has created a résumé and separated the sections using headings. How can he set the headings apart from normal text?
Pepsi [2]
He could use bold or bigger text just a suggestion.
6 0
3 years ago
Write any 2 differences between implicit variables and explicit variables.​Plz tell :' (
Marrrta [24]
Explicit is stated very clearly
Implicit is implied
Explicit leaves no room for confusion
Implicit doesn’t have to be directly stated
3 0
3 years ago
Consider the following code segment: try : inputFile = open("lyrics.txt", "r") line = inputFile.readline() print(line) _________
aleksandrvk [35]

Answer:

The answer is "except IOError:"

Explanation:

It is part of the exception handling, that stands for input/ output operation fails, this exception aeries when we attempting to access an anti-existent file, in the program so, it will give the program related errors.

  • This type of error is handled in the try block, it also allows you to prepare the deal with the exceptional block.  
  • It also helps you to hide the bugs by using code, if you handle an unexpected error.
6 0
3 years ago
Calls to the tostring( ) method emphasize the use of ____.
DaniilM [7]
<span>Polymorphic message
   
Methods in different classes with a similar function are given the same name. - Makes classes easier to use because programmers need to remember fewer method names. - Employed as much as possible. - Polymorphic message ex. is the toString method.</span>
5 0
3 years ago
Other questions:
  • A. True
    6·1 answer
  • A computer has a memory ________, rather than just a single memory component. The lowest level is some form of ________ storage
    11·1 answer
  • What is credibility in the often-used framework of quality criteria?
    9·1 answer
  • Which of these options would likely have a better playback experience in your presentation?
    8·2 answers
  • Recently, your laptop won't power on, and the battery is not charging. You suspect the block on the power cord (also known as a
    5·1 answer
  • What will be displayed if the following Java code segment is run? System.out.println("one "); System.out.print("two "); System.o
    12·1 answer
  • What will the following code print out: int numbers [] = {99, 87, . 66, 55, 101}; for (int i = 1; i &lt; 4; i++) cout &lt;&lt; n
    11·1 answer
  • Does -8 = -21?<br>[this is NOT a trick question]<br>Yes....?<br>No!​
    12·2 answers
  • 9. What command do you enter in the Explorer search box to access the Remote Admin share on the computer named Fin?
    7·1 answer
  • Which example best demonstrates an impact of computers on the economy?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!