Hey im quite new to java and my friends have been helping me out
however ive stumbled upon a question im not quite sure how to solve.
i need to find the max,min and avg of the total 'responses'
im not quite sure how to bring the values from the 'response' over since the numbers arent generated until a user inputs a few numbers.
my work so far:
import java.util.*;
public class fluffpuff {
public int board[];
public void runsurvey() {
}
{
Scanner in = new Scanner(System.in);
//user:
int choice = 0;
int surveyed =0;
int response = 0;
//total:
int average;
int max;
int min;
//How many people are to be surveyed?
while(choice==0)
{
System.out.print("How many people are to be surveyed?");
surveyed = in.nextInt();
if(surveyed<0) {
System.out.println("Illegal input, must be >= 1. Try again");
} else {
choice++;
}
}
board = new int[surveyed];
//Please enter response
int counter = 0;
while(choice==1)
{
while(counter<surveyed)
{
Scanner reader = new Scanner(System.in);
System.out.print("Please enter response: ");
response = reader.nextInt();
if(response<0) {
System.out.println("Illegal input, must be 0..9, Try again");
} else {
board[counter] = response;
counter++;
}
}
choice++;
}
displayboard(surveyed);
}
//Graph of response
public void displayboard(int surveyed)
{
int row;
int count;
row = 0;
while (row < surveyed)
{
count=0;
while(count<board[row]) {
System.out.print("*");
count++;
}
row++;
System.out.println("");
}
//Max
//Min
//Average