Java Tutorial with Java Code Examples

Java Basics | String | Date | Collection | Java Map | Java Util | File I/O | XML | Threading | Network | i18n | Misc
Java Swing | JDBC | Servlet | JSP | JSTL | JMS | EJB | JPA | JSF | Struts | Spring | Hibernate
Web Services | Java PDF | JUnit | Ant | HTML | JavaScript | Apache | Tomcat | SQL | T-SQL | PL/SQL | MySQL

Java Basics

Introduction

Data Types and Arrays

Get User Input

Data Type Conversions

Control Flow

Handling Exception

 

  Java Basics » Control Flow » Nested if else if

  Java Code Example:  IfElseIfExample.java  Download Sample Source Code

/*
 * Copyright © 2008 - 2009 it.ibluespace.com. All rights reserved.
 */
import java.util.Scanner; public class IfElseIfExample { public static void main(String args[]) { System.out.println("Enter your score : "); Scanner sc = new Scanner(System.in); int score = sc.nextInt(); if ( score >= 90 ) { System.out.println("Excellent"); } else if ( score >= 80 ) { System.out.println("Good"); } else if ( score >= 70 ) { System.out.println("Satisfied"); } else if ( score >= 60 ) { System.out.println("Not too bad"); } else { System.out.println("Need to improve"); } } }
 Download Source Code: IfElseIfExample.java

The command executed and output produced:


E:\JavaEECoding\>java IfElseIfExample
Enter your score :
82
Good

Search for Java code examples on this site

 
 

Resources

Java Tutorial

Java World

Java SE 6 API Doc


Terms of Use  |  License  Copyright 2008-2009 it.ibluespace.com. All rights reserved.  | 
All other trademarks are the property of their respective owners.