// // sketch of all-purpose conversion program // prompts for what type of conversion, then number to convert // val CmPerInch = 2.54 def inchesToCm(inches : Double) : Double = inches * CmPerInch def cmToInches(cm : Double) : Double = cm / CmPerInch def getInputNumber() : Double = { println("enter a number to convert") readDouble } def repeatConversion() { println("enter 'i' for inches to cm, 'c' for cm to inches, 'q' to quit") val which = readChar if (which == 'q') { } else if (which == 'i') { println(inchesToCm(getInputNumber()) + " cm") repeatConversion() } else if (which == 'c') { println(cmToInches(getInputNumber()) + " inches") repeatConversion() } else { println("not a valid choice") repeatConversion() } } repeatConversion()