* * Experiment with IfThenElse */ // File: CMIS 141 Week 2 Discussion // Author: Jacqueline Fox // Date: 02/11/2016 // Title: If Then assigns childname based on age Test If ThenElsechildname { public static void main (String[] args{ int age = 0; childname = JD; if (age = 13) { print childname = "Tee"; } else if (age = 11) { print childname = '="AnayaBoo"; } else if (age = 9) { print childname = "Niya"; } else if (age =0) { print childname = "JD"; } else { age= print "wrongchild"; } System.out.println (age = " + childname); float avg, fahrenheit,celsius; // Variables to hold values // Use the Scanner class to input data Scanner scannerIn; scannerIn = new Scanner(System.in); do{ System.out.print("Enter your Student EMPLID : "); EMPLID = scannerIn.nextInt(); }while(emplidCheck(EMPLID)); do{ System.out.print("Enter your quiz1 percentage score (0.0 - 100.0) : "); quiz1 = scannerIn.nextInt(); }while(quizCheck(quiz1)); do{ System.out.print("Enter your quiz2 percentage score (0.0 - 100.0) : "); quiz2 = scannerIn.nextInt(); }while(quizCheck(quiz2)); do{ System.out.print("Enter your quiz3 percentage score (0.0 - 100.0) : "); quiz3 = scannerIn.nextInt(); }while(quizCheck(quiz3)); int years = 0; System.out.print("Your age in months = "); years = scannerIn.nextInt(); int original_years = results; results = years / 12; System.out.println("Your age in years = " + results); int original_results= years; System.out.print("Enter the current Temperature in degrees Celsius : "); temperature = scannerIn.nextInt(); System.out.print("Enter the current Temperature in degrees Fehrenheit : "); temperature = scannerIn.nextInt(); sum = quiz1 + quiz2 + quiz3; avg = sum/3; fahrenheit = toCelsius(temperature); celsius = toFahrenheit(temperature); System.out.print("\nStudent EMPLID = " +EMPLID); System.out.print("\nQuiz 1 Score = " +quiz1); System.out.print("\nQuiz 2 Score = " +quiz2); System.out.print("\nQuiz 3 Score = " +quiz3); System.out.printf("\nAverage quiz score = " +avg); System.out.print("\nYour age in months = " + years); System.out.print("\nYour age in years = "+ results); System.out.print("\nTemperature in Celsius = " +fahrenheit +"°"); System.out.print("\nTemperature in Fahrenheit = " +celsius +"°"); } public static float toCelsius(float fahrenheit) { float celsius = (fahrenheit - 32) * 5/9; return celsius; }//end of function toCelsius public static float toFahrenheit(float celsius) { float fahrenheit = (celsius + 32) * 9/5; return fahrenheit; }//end of function toCelsius public static boolean quizCheck(float per) { boolean res; if(per <0 || per >100) { System.out.print("\nQuiz percentage out of range."); res = true; } else res =false; return res; }//end of quizCheck public static boolean emplidCheck(int id) { boolean res; if(id <=999999 && id >=0) res =false; else { System.out.print("\nInvalid ID."); res = true; } return res; }//end of emplidCheck }//end of class