In: Computer Science
I need a java flowchart diagram for the following code:
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("Enter the input
size: ");
int n=sc.nextInt();
int arr[]=new int[n];
System.out.print("Enter the
sequence: ");
for(int i=0;i<n;i++)
arr[i]=sc.nextInt();
if(isConsecutiveFour(arr))
{
System.out.print("yes the array
contain consecutive number:");
for(int i=0;i<n;i++)
System.out.print(arr[i]+" ");
}
else
System.out.print("Not a consecutive
sequence");
}
public static boolean isConsecutiveFour(int[]
values){
int c=0;
//consecutive seq :- 1 2 3 4 5
whose dffirence is 1
for(int
i=0;i<values.length-1;i++)
{
if(values[i]+1==values[i+1])
c++;
}
if(c+1==values.length)
return true;
else
return false;
}
}
The given java program performs the below operations:
=========================================================
Flow chart for the given program is as below:
======================
Flowchart Description