I'm new to awt and file and I stumble on an exercise in a book. I'm trying to do it but it doen't seems quite right. Can anyone help? If possible mind to code the whole thing for my reference? This is my question:
Write a program that will evaluate data from questionnaires of the following form:
1. There are three groups of questions on each questionnaire. The first group has four questions, the second group has eight questions, and the third group has seven questions.
2. Each question will be answered with a number between one and five, inclusively with the following meaning : 1 = strongly disagree 2 = disagree 3 = don't care 4 = agree 5 = strongly agree
Write a program that will required to do the following for each questionnaire: a. Use a method called average to find the average response for each group of questions. b. Use a method called histogram to draw a histogram showing the average responses to the three groups of questions. c. Use a method called opinion to display the respondent's average opinion for each of the three groups of questions.
You will process an unknown number of questionnaires.
The company prefers graphical user interfaces to be used.
Input: When a person answers the questionnaire, his answers are stored in a text file called Data.txt, in the following manner: Column 1-3 ID number of the person ( 3 digit of type integer )
Column 5-8 The four responses to the questions in group 1, one column each (each is an integer between 1 and 5, inclusively )
Column 10-17 The eight responses to the questions in group 2, one column each (each is an integer between 1 and 5, inclusively )
Column 19-25 The seven responses to the questions in group 3, one column each (each is an integer between 1 and 5, inclusively )
You are given the specifications for the methods above as described below. Include necessary comments on the design/specification of these methods.
average method's specification Write a general method called average which has as its argument an integer array ( the answers to the questions of a particular group ) and the length of the array ( the number of questions). The average method should compute the average of the numbers in the array, and return the average value of type integer. You may use this same method three times for each questionnaire to find the average response for each of the three groups of questions. Note: Be careful of integer division!
Histogram method's specification Write a method, called histogram, which accepts one argument, the array of averages of the three groups of questions. The method histogram should make a histogram of the three averages using the coding and description that follow:
For each point an asterisk ( you may use icon or other representation of the point ) is displayed. For example, if the average response for group 3 is 4, then 4 asterisks will be displayed. The following histogram shows what would be displayed if the averages were 3, 4, and 5 for the three groups, respectively.
opinion method's specification Write a method called opinion that accepts two arguments. The first is an integer variable which represents the respondent's ID number. The second argument is an integer array containing the averages of the three groups of questions. This method should display the following messages in capital letters:
1. If the average is 1, the person STRONGLY DISAGREES. 2. If the average is 2, the person DISAGREES. 3. If the average is 3, the person DOES NOT CARE. 4. If the average is 4, the person AGREES. 5. If the average is 5, the person STRONGLY AGREES.
Sample output for the three groups of questions :
ID Number:999 View about Group 1 Questions is XXXXXXXXX View about Group 2 Questions is XXXXXXXXX View about Group 3 Questions is XXXXXXXXX
The 999 is to be replaced by the person's ID number, and XXXX is to be replaced by the appropriate message/opinion.