Question
( Student Poll ) Figure 7.8 contains an array of survey responses thats hard coded into the program. Suppose we wish to process survey results
(Student Poll) Figure 7.8 contains an array of survey responses thats hard coded into the program. Suppose we wish to process survey results that are stored in a file. This exercise requires two separate programs. First, create an application that prompts the user for survey responses and outputs each response to a file. Use a Formatter to create a file called numbers.txt. Each integer should be written using method format. Then modify the program in Fig. 7.8 to read the survey responses from numbers.txt. The responses should be read from the file by using a Scanner. Use method nextInt to input one integer at a time from the file. The program should continue to read responses until it reaches the end of the file. The results should be output to the text file "output.txt".
Figure 7.8
I // Fig. 7.8: StudentPo11.java 2 // Po11 analysis program 4 public class StudentPo11 public static void main(String] args) // student response array (more typically, input at runtime) int[] responses-1, 2, 5, 4, 3, 5, 2, 1, 3, 3, 1, 4, 3, 3, 3, 2, 3, 3, 2, 14 int[] frequencynew int[6]; // array of frequency counters 10 12 13 I for each answer, select responses element and use that value // as frequency index to determine element to increment for (int answer = 0; answerStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started