In: Computer Science
PLEASE USE THE FLOWORITHM APPLICATION FOR THE ANSWER . I need that not a flowchart .Design the logic for a program that takes in three numbers from the user. Find the largest of the three numbers and output the largest number.
Greetings !
Logic to find the largest among three numbers:
if (first >= second) {
if (first >= third)
print(" first is the largest number");
else
print(" third is the largest number");
} else {
if (second >= third)
print(" second is the largest number");
else
print(" third is the largest number");
}
// Implementation of above logic in flowgorithm
screenshot of the output:
Pseudocode of the algorithm generated by flowgorithm application:
Function Main
Declare Integer first
Declare Integer second
Declare Integer third
Output "Enter first number"
Input first
Output "Enter second number"
Input second
Output "Enter third number"
Input third
If first > second
If first > third
Output first & " is the largest number"
False:
Output third & " is the largest number"
End
False:
If second > third
Output second & " is the largest number"
False:
Output third & " is the largest number"
End
End
End
Java cource code generated by flowgorithm application:
import java.util.*;
import java.lang.Math;
public class JavaApplication {
private static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
int first;
int second;
int third;
System.out.println("Enter first number");
first = input.nextInt();
System.out.println("Enter second number");
second = input.nextInt();
System.out.println("Enter third number");
third = input.nextInt();
if (first > second) {
if (first > third) {
System.out.println(Integer.toString(first) + " is the largest number");
} else {
System.out.println(Integer.toString(third) + " is the largest number");
}
} else {
if (second > third) {
System.out.println(Integer.toString(second) + " is the largest number");
} else {
System.out.println(Integer.toString(third) + " is the largest number");
}
}
}
}