// Create a method called calcFeetAndInchesToCentimeters
// It needs to have two parameters.
// feet is the first parameter, inches is the 2nd parameter
//
// You should validate that the first parameter feet is >= 0
// You should validate that the 2nd parameter inches is >=0 and <=12
// return -1 from the method if either of the above is not true
//
// If the parameters are valid, then calculate how many centimetres
// comprise the feet and inches passed to this method and return
// that value.
//
// Create a 2nd method of the same name but with only one parameter
// inches is the parameter
// validate that its >=0
// return -1 if it is not true
// But if its valid, then calculate how many feet are in the inches
// and then here is the tricky part
// call the other overloaded method passing the correct feet and inches
// calculated so that it can calculate correctly.
// hints: Use double for your number datatypes is probably a good idea
// 1 inch = 2.54cm and one foot = 12 inches
// use the link I give you to confirm your code is calculating correctly.
// Calling another overloaded method just requires you to use the
// right number of parameters.
Example in the course:

Java Coding Methods Overloading Challenge
package com.company; import java.util.SortedMap; public class Main { public static double calcFeetAndInchesToCentimetres(int feet, int inches) { if (feet >= 0 && inches >= 0 && inches <= 12) { double feetToCentimetres = (feet * 12) * 2.54; double inchesToCentimetres = inches * 2.54; return feetToCentimetres + inchesToCentimetres; } else System.out.println("Invalid Feet or Inches"); return -1; } public static double calcFeetAndInchesToCentimetres(int inches) { if (inches >= 0) { int inchesToFeet = inches / 12; int remainingInches = inches % 12; return calcFeetAndInchesToCentimetres(inchesToFeet,remainingInches); } else System.out.println("Invalid Feet or Inches"); return -1; } public static void main(String[] args) { System.out.println(calcFeetAndInchesToCentimetres(36)); System.out.println(calcFeetAndInchesToCentimetres(84,11)); } }
package com.company; public class Main { public static void main(String[] args) { calcFeetAndInchesToCentimeters(12, 9); calcFeetAndInchesToCentimeters(9); } public static void calcFeetAndInchesToCentimeters(int feet, int inches) { if (feet >= 0 && inches >= 0 && inches < 12) { double AnswerInches = inches * 2.54; double AnswerFeet = feet * 30.48; double AnswerCentimeters = AnswerFeet + AnswerInches; System.out.println(feet + " feet and " + inches + " inches is " + AnswerCentimeters + " centimeters."); } else { System.out.println(-1); } } public static void calcFeetAndInchesToCentimeters(int inches) { if (inches >= 0 && inches < 12) { double AnswerCentimeters = inches * 2.54; System.out.println(inches + " inches is " + AnswerCentimeters + " centimeters."); } else { System.out.println(-1); } } }