/* MultiwayBranch2.java CIS 160 David G. Klick 2007-09-25 Demonstrates nested if-then-else for multiway branching. This code is easy to turn into a flowchart, but requires a lot of typing and indentation. */ import java.util.Scanner; public class MultiwayBranch2 { public static void main(String[] args) { Scanner kbd = new Scanner(System.in); System.out.print("What month number is it? "); int month = kbd.nextInt(); System.out.print("Month number " + month + " is "); if (month == 1) { System.out.println("January"); } else { if (month == 2) { System.out.println("February"); } else { if (month == 3) { System.out.println("March"); } else { if (month == 4) { System.out.println("April"); } else { if (month == 5) { System.out.println("May"); } else { if (month == 6) { System.out.println("June"); } else { if (month == 7) { System.out.println("July"); } else { if (month == 8) { System.out.println("August"); } else { if (month == 9) { System.out.println("September"); } else { if (month == 10) { System.out.println("October"); } else { if (month == 11) { System.out.println("November"); } else { if (month == 12) { System.out.println("December"); } else { System.out.println("not a valid month number"); } } } } } } } } } } } } } }