logo

UrgentHomeWork

+1-617-874-1011 (US)
+44-117-230-1145 (UK)
+61-7-5641-0117 (AU)
help@urgenthomework.com

Available 24 x 7 Assignment Help

With Tutoring

Java Decision Making Homework Help

Java Decision Making

The decision making structures is used to check the condition and produces Boolean based result depends it statement will execute. Java has following types of decision making statements.

1. If statement

2. If…else statement

3. Nested if statement

4. Switch statement

If statement:

It is executed based on Boolean statement.

Syntax:

If (condition)

{

Statements;

}

Example:

{`public class sample {  ;
 public static void main(String args[])
 {  ;
 int i = 20;
 if( i < 30 )
 {  ;
 System.out.print("if statement");
 }  ;
 }  ;
 }  ;`}

Output:

if statement

if…else statement:

it can follow by else statement. When the Boolean statement false it will be executed.

Syntax:

If (condition)

{

Statements;

}

else

{

Statement;

}

Example:

{`public class sample {  ;
 public static void main(String args[])
 {  ;
 int i = 40;
 if( i < 30 )
 {  ;
 System.out.print("if statement");
 }  ;
else
{  ;
 System.out.print("else statement");
}  ;
}  ;
 }  ;
`}

Output:

else statement

if …else if statement:

it can follow by else if statement. When the Boolean statement false it will be again check another condition and executed.

Syntax:

If (condition)

{

Statements;

}

else if(condition)

{

Statement;

}

else

{

Statement;

}

Example:

{`public class sample  {  ;
 public static void main(String args[])
 {  ;
 int i = 40;
 if( i == 30 )
 {  ;
 System.out.print(" I = 30");
 }  ;
else (i==40)
{  ;
 System.out.print("I = 40");
 }  ;
else
{  ;
 System.out.print("no value");
}  ;
}  ;
 }  ;
`}

Output:

I = 40

Nested if statement:

The want to check more than one condition means we use nested if that if with if statement.

Syntax:

If (condition1)

{

If(condition2)

{

Statement

}

}

Example:

{`public class sample
{  ;
 public static void main(String args[])
 {  ;
 int i = 40;
 int j = 20;
 if( i == 40 )
 {  ;
 if( j == 20 )
 {  ;
System.out.print("i = 40 and j = 20");
}  ;
 }  ;
 }  ;
 }  ;
`}

Output:

i = 40 and j = 20

Switch Statement:

It is used to test the list of values. The variable is checked for each case.

Syntax:

Switch(expression)

{

Case value:

Statements

Break; (optional)

Case value:

Statements

Break; (optional)

Default: (optional)

Statements

}

Example:

{`public class sample  {  ;
 public static void main(String args[])
 {  ;
 int mark = '75';
 switch(mark)
 {  ;
 case '75' :
System.out.println("first class");
break;
 case '65' :
 case '60' :
System.out.println("second class");
break;
 default :
System.out.println("Invalid mark");
}  ;
 System.out.println("Your mark is " + mark);
 }  ;
 }  ;
`}

Output:

first class

Your mark is 75

Calculator
Simple Calculator
Scientific Calculator
EMI Calculator
Mortgage Calculator
Love Calculator
Percentage Calculator
Currency Calculator
Units Converter
Graph Calculator
Financial Lease Calculator
Temperature Converter
Resources
24 x 7 Availability.
Trained and Certified Experts.
Deadline Guaranteed.
Plagiarism Free.
Privacy Guaranteed.
Free download.
Online help for all project.
Testimonial

Urgenthomework helped me with finance homework problems and taught math portion of my course as well. Initially, I used a tutor that taught me math course I felt that as if I was not getting the help I needed. With the help of Urgenthomework, I got precisely where I was weak:

logo

  Urgent HomeWork

Disclaimer: The study tools and academic assistance/guidance through online tutoring sessions provided by Urgenthomework.com is to help and enable students to compete academically. The website does not provide ghostwriting services and has ZERO TOLERANCE towards misuse of the services. In case any user is found misusing our services, the user's account will be immediately terminated.
Copyright © 2009-2022 UrgentHomework.com, All right reserved.