10:13 am - Wednesday December 19, 2018

Java Example Program using IF statement

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

/* Program for if statement */
/**
 * @author:Candidjava.com
 * @Description:Find the charges for current units using if statement
 */
public class Units {
	public static void main(String args[]) {
		int i = 1003, u;
		// check the condition
		if (i > 500) {
			// this operation for calculate the amount
			u = i * 5;
			// print the output
			System.out.println("The Amount is:" + u);
		} else if (i > 100) {
			// this operation for calculate the amount
			u = i * 4;
			// print output
			System.out.println("The Amount is:" + u);
		} else if (i > 50) {
			// this operation for calculate the amount
			u = i * 3;
			// print the output
			System.out.println("The Amount is:" + u);
		}
		// check the condition
		else if (i > 25) {
			u = i * 2;
			System.out.println("The Amount is:" + u);
		} else {
			u = i * 1;
			// print the output
			System.out.println("The Amount is:" + u);
		}
	}
}



 

OUTPUT:
The Amount is:5015

Filed in: Z-A All Java Codes

Comments are closed.