Implement the following flow chart in Java You should have o
Solution
Problem1.java:
package org.chegg;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.Scanner;
public class Problem1 {
static int k;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println(\"Enter K value:\");
k = sc.nextInt();
int a[] = GenerateData();
try{
FileWriter fw = new FileWriter(\"F:\\\\output.txt\");
BufferedWriter bw = new BufferedWriter(fw);
for(int i=0;i<a.length;i++){
bw.write(String.valueOf(a[i]));
bw.newLine();
}
System.out.println(\"data stored in to output.txt successfully\");
bw.close();
fw.close();
}
catch(Exception e){
e.printStackTrace();
}
}
public static int[] GenerateData(){
int n=0;
int a[] = new int[k];
while(n<k){
a[n] = n*100;
n = n+ 1;
}
return a;
}
}
Output.txt:
0
100
200
300
400
500
600
700
800
900
1000
1100
Sample Input & Output:
Enter K value:
12
data stored in to output.txt successfully

