Purchase Solution

function convert Length

Not what you're looking for?

Ask Custom Question

Write a function convertLength() that receives a real value and two strings inUnits and outUnits, then converts the value given in inUnits to the equivalent metric value in outUnits and displays this value. The function should carry out the following conversions:
inUnits outUnits
I c (inches to centimeters; 1 in. = 2.54001 cm)
F c (feet to centimeters; 1 ft = 30.4801cm)
F m (feet to meters; 1 ft = 0.304801 m)
Y m (yards to meters; 1 yd = 0.914402 m)
M k (miles to kilometers; 1 mi = 1.60935 km)

Also write a driver program to test your function. What happens if you enter units other than those listed?

Purchase this Solution

Solution Summary

Write a function convertLength() that receives a real value and two strings inUnits and outUnits, then converts the value given in inUnits to the equivalent metric value in outUnits and displays this value.

Purchase this Solution


Free BrainMass Quizzes
Javscript Basics

Quiz on basics of javascript programming language.

C# variables and classes

This quiz contains questions about C# classes and variables.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Basic Networking Questions

This quiz consists of some basic networking questions.