Write a simple polling program that: - Allows users to rate five social-consciou
ID: 666941 • Letter: W
Question
Write a simple polling program that: - Allows users to rate five social-consciousness issues from 1 (least important) to 10 (most important); - Pick five causes that are important to you (e.g., political issues, global environmental issues). Use a one- dimensional array topics (of type String) to store the five causes; To summarize the survey responses, use a 5-row, 10-column two-dimensional array responses (of type int): - Each row corresponding to an element in the topics array. When the program runs, it should ask the user to rate each issue. People in the range of (5, 13) have respond to the survey. Then have the program display a summary of the results, including: a) A tabular report with the five topics down the left side and the 10 ratings across the top, listing in each column the number of ratings received for each topic. b) To the right of each row, show the average of the ratings for that issue. c) Which issue received the highest point total? Display both the issue and the point total. d) Which issue received the lowest point total? Display both the issue and the point total.Explanation / Answer
import java.util.Scanner;
public class polling {
static String[] s={"first question","second question","Third Question","fourth Question","Fifth Questio"};//here you edit your issues
static int[][] f=new int[5][10];
public static void main(String[] args){
double[] sum=new double[]{0,0,0,0,0};
double avg=0;
Scanner inp=new Scanner(System.in);
for(int i=0;i<10;i++){
for(int j=0;j<5;j++){
System.out.println("Give your Rating between 1-10 for the Issue "+(j+1)+"."+s[j]);
f[j][i]=inp.nextInt();
}
}
System.out.println("Responses");
for(int i=0;i<5;i++){
System.out.print(" "+(i+1)+"."+s[i]);
for(int j=0;j<10;j++){
System.out.print(f[i][j]+" ");
sum[i]=sum[i]+f[i][j];
}
avg=sum[i]/10;
System.out.print("Average="+avg);
}
double max=sum[0],min=sum[0];
int maxI=0,minI=0;
for(int i=0;i<5;i++){
if(max<sum[i]){
max=sum[i];
maxI=i;
}
if(min>sum[0]){
min=sum[0];
minI=i;
}
}
System.out.println("MaximumRated Issue"+s[maxI]+" Ratings:"+max);
System.out.println("Minimum rated Issue"+s[minI]+" Ratings"+min);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.