Implement the following flow chart in Java You should have o
Solution
// Project1.java
import java.util.*;
import java.io.FileWriter;
public class Project1
{
public static void generateData(int[] array, int k)
{
int n = 0;
while (n < k)
{
// add n*100 to arra
array[n] = n*100;
// increment n
n = n + 1;
}
}
public static void main(String[] argv) throws Exception
{
// scanner object (called input).
Scanner input = new Scanner(System.in);
FileWriter fw = new FileWriter(\"output.txt\");
System.out.print(\"Enter integer k: \");
int k = input.nextInt();
// array of k integers
int array[]=new int[k];//declaration and instantiation
generateData(array, k);
// write array data to file
for (int i = 0; i < array.length; i++)
{
fw.write(array[i] + \"\\t\");
}
fw.close();
}
}
/*
output:
Enter integer k: 10
output.txt
0 100 200 300 400 500 600 700 800 900
*/
