Hello I am confused on how to code this, if you follow the directions of the tas
ID: 3799970 • Letter: H
Question
Hello I am confused on how to code this, if you follow the directions of the task it will help to create the code.
A3.15 Java example: Search for name using branches 3.16 Lab 3a Due 28-Feb-17 Students: This content is controlled by your instructor, and is not zyBooks content. Direct questions or concerns about this content to your instructor. If you have any technical issues with the zyLab submission system, use the Trouble with lab?" button at the bottom of the lab. Lab3a Introduction In this lab you will be diving into control flow statements, specifically conditional statements. These types of statements are based upon boolean logic. This type of logic is based on the concept of true-false. So boolean values can have the value of either true or false. There are two major types of conditional statements: if-then-else switch-case lf-Then-Else are statements that operate such that if some condition evaluates to true, then do something. Else you do this. For these statements if and else are the keywords if (/*some condition Do some stuff here else if /*some other condition* Do something here else Do some other thingExplanation / Answer
import java.util.Scanner;
public class FlowControlDemo {
public static void main(String[] args) {
// to read the input from the user we need scanner object.
Scanner scanner = new Scanner(System.in);
// to read the values from the user
System.out
.println("enter three integers for display them in ascending and descending");
int n1=scanner.nextInt();//to read the integer using scanner
int n2=scanner.nextInt();
int n3=scanner.nextInt();
if (n1 > n2) {
int temp = n1;
n1 = n2;
n2 = temp;
}
else if (n2 > n3) {
int temp = n2;
n2 = n3;
n3 = temp;
}
else if (n1 > n2) {
int temp = n1;
n1 = n2;
n2 = temp;
}
System.out.println("The ascending order is "
+ n1 + " " + n2 + " " + n3);
System.out.println("the descending order is " + n3 + " " + n2 + " " + n1);
}
}
output
enter three integers for display them in ascending and descending
25
10
98
The ascending order is 10 25 98
the descending order is 98 25 10
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.