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
When can design templates be applied to the presentation?
Sophie [7]

Answer:

when you add a new slide

Explanation:

I think it's correct

8 0
3 years ago
Prime numbers can be generated by an algorithm known as the Sieve of Eratosthenes. The algorithm for this procedure is presented
Sidana [21]

Answer:

const MAXNR=150;

let candidates = {};

for(let i=2; i<=MAXNR; i++) {

   candidates[i] = true;

}

for(let p=2; p <= MAXNR; p++) {

   if (candidates[p]) {

       process.stdout.write(`${p} `);

       // Now flag all multiples of p as false

       i=2;

       while(p*i <= MAXNR) {

           candidates[p*i] = false;

           i++;

       }

   }

}

4 0
3 years ago
Sukhi needs to insert a container into her form to collect a particular type of information.
Hunter-Best [27]

Answer:

text box

Explanation:

on edge 2020

6 0
4 years ago
Is a collection of information stored under a single name ​
oksian1 [2.3K]

\boxed{ File  } is a collection of information stored under a single name.

\bold{ \green{ \star{ \orange{Mystique35}}}}⋆

3 0
3 years ago
Read 2 more answers
You used this code to give the user hints.
MakcuM [25]

Answer:

Elif guess < correct

Else

Explanation:

So, you need to insert right condition that compatible with given code, so firstly you need to print that guess was higher  and then if it is not correct and it is not higher  print that it was actually lower.

8 0
3 years ago
Other questions:
  • How can I change it to accepted file types: .ppt, .pptx, .xls, .xlsx, .doc, .docx, .zip, .pdf, .accdb, .msg on Inkscape?
    15·2 answers
  • To enable a compute or device that does not have built-in networking capability, use a(n) ______.
    13·1 answer
  • Which function will add a grade to a student's list of grades in Python? add() append() print() sort()
    5·2 answers
  • A(n) ____________ is special high-speed memory that allows a microprocessor to access data more rapidly than from memory located
    14·2 answers
  • The function of the file server is to : 1. store data and software programs that can be used by client computers on the network.
    12·1 answer
  • In the Mouse Properties window, you can?
    8·1 answer
  • A(n) _______ is a distributed networking architecture, residing on one or more computers, where one program requests a resource
    14·1 answer
  • A. Fill in the blanks:
    6·1 answer
  • A processor's speed is measured in megahertz (MHz), or millions of instructions per second; and gigahertz (GHz), or billions of
    9·2 answers
  • What is the role of the computer in banking system?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!