How to get my Java 'if' statement to work? - java

I am very new to learning Java and currently I am working on a program that lets me fight the computer based on simple stats that I have assigned us and a random number to function as a dice roll. I recognize that there may be numerous other problems with my code, but the main issue I am trying to resolve is the "Syntax error on tokens, delete these tokens" on line 84 and the "Syntax error, insert "}" to complete Statement" on line 77.
I don't see what the issue is. What am I doing wrong? Both issues are listed near the bottom of my code in comments next to their corresponding lines.
import java.util.Scanner;
import java.util.Random;
public class Fight {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter your name");
String you = keyboard.next();
int youWounds = 1;
int youTough = 4;
int youAttack = 1;
int youWS = 4;
int youAS = 3;
String Comp = "Bad Guy";
int compWounds = 1;
int compTough = 4;
int compAttack = 1;
int compWS = 4;
int compAS = 3;
System.out.println(you + ", do you want to FIGHT?!?!?");
System.out.println("Yes / No?");
String inputString = keyboard.next();
if (inputString.equalsIgnoreCase("Yes")) {
System.out.println("FIGHT!!!!");
while (youWounds > 0 && compWounds > 0) {
int youRan = new Random().nextInt(6)+1; // this is where you roll to hit
System.out.println(you + " rolls " + youRan +" to hit");
if (youRan >= 7-youWS) { // this is the logic for roll to hit
System.out.println(you +" hit");
int youRanTW = new Random().nextInt(6)+1; // this is where you check to see if your hit wounds
System.out.println(you + " rolls " + youRanTW +" to wound");
if (youRanTW > compTough) { // this is the logic for roll to wound
System.out.println(you+" wounds"+Comp);
compWounds = compWounds - 1; // this is where comp loses a wound
if (compWounds <= 0) { // this is the logic for wound loss
System.out.println(Comp+" dies!!!");
} else {
System.out.println("But, "+Comp+" fights on!");
}
} else {
System.out.println(you=" does not wound");
}
} else {
System.out.println(you +" misses");
}
int compRan = new Random().nextInt(6)+1;
System.out.println(Comp+" rolls " + compRan + " to hit");
if (compRan >= 7-compWS) { // this is the logic for roll to hit
System.out.println(Comp +" hit");
int compRanTW = new Random().nextInt(6)+1; // this is where you check to see if your hit wounds
System.out.println(Comp + " rolls " + compRanTW +" to wound");
if (compRanTW > youTough) { // this is the logic for roll to wound
System.out.println(Comp+" wounds"+you);
youWounds = youWounds - 1; // this is where you loses a wound
if (youWounds <= 0) { // this is the logic for wound loss
System.out.println(you+" dies!!!");
} else {
System.out.println("But, "+you+" fights on!");
}
} else {
System.out.println(Comp=" does not wound");
}
} else {
System.out.println(Comp +" misses");
}
} else { // this is wher I get "Syntax error, insert "}" to complete Statement". The "}" is underlined in red on my screen
if (youWounds <=0){
System.out.println(Comp+" WINS!!!!");
} else {
System.out.println(you+" WINS!!!!");
}
}
} else { // this is where i get "Syntax error on tokens, delete these tokens". it wants me to delete "} else".
System.out.println(you + " you are a looser!!!!!!!!");
}
keyboard.close();
}
}

There are a few issues with the flow of your program, but the current problem is that you are trying to use else on your while loop. This is not possible or necessary.
The while loop will continue until the defined condition is met. Once that happens, the while loop ends and the next line of code is executed.
So, remove the else { from the closing of the while loop. You can then just evaluate the results.
Here's the corrected code, with a couple comments to show WHERE to remove things:
import java.util.Random;
import java.util.Scanner;
public class Fight {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter your name");
String you = keyboard.next();
int youWounds = 1;
int youTough = 4;
int youAttack = 1;
int youWS = 4;
int youAS = 3;
String Comp = "Bad Guy";
int compWounds = 1;
int compTough = 4;
int compAttack = 1;
int compWS = 4;
int compAS = 3;
System.out.println(you + ", do you want to FIGHT?!?!?");
System.out.println("Yes / No?");
String inputString = keyboard.next();
if (inputString.equalsIgnoreCase("Yes")) {
System.out.println("FIGHT!!!!");
while (youWounds > 0 && compWounds > 0) {
int youRan = new Random().nextInt(6) + 1; // this is where you roll to hit
System.out.println(you + " rolls " + youRan + " to hit");
if (youRan >= 7 - youWS) { // this is the logic for roll to hit
System.out.println(you + " hit");
int youRanTW = new Random().nextInt(6) + 1; // this is where you check to see if your hit wounds
System.out.println(you + " rolls " + youRanTW + " to wound");
if (youRanTW > compTough) { // this is the logic for roll to wound
System.out.println(you + " wounds" + Comp);
compWounds = compWounds - 1; // this is where comp loses a wound
if (compWounds <= 0) { // this is the logic for wound loss
System.out.println(Comp + " dies!!!");
} else {
System.out.println("But, " + Comp + " fights on!");
}
} else {
System.out.println(you = " does not wound");
}
} else {
System.out.println(you + " misses");
}
int compRan = new Random().nextInt(6) + 1;
System.out.println(Comp + " rolls " + compRan + " to hit");
if (compRan >= 7 - compWS) { // this is the logic for roll to hit
System.out.println(Comp + " hit");
int compRanTW = new Random().nextInt(6) + 1; // this is where you check to see if your hit wounds
System.out.println(Comp + " rolls " + compRanTW + " to wound");
if (compRanTW > youTough) { // this is the logic for roll to wound
System.out.println(Comp + " wounds" + you);
youWounds = youWounds - 1; // this is where you loses a wound
if (youWounds <= 0) { // this is the logic for wound loss
System.out.println(you + " dies!!!");
} else {
System.out.println("But, " + you + " fights on!");
}
} else {
System.out.println(Comp = " does not wound");
}
} else {
System.out.println(Comp + " misses");
}
} // REMOVE THE ELSE AND BRACKET
if (youWounds <= 0) {
System.out.println(Comp + " WINS!!!!");
} else {
System.out.println(you + " WINS!!!!");
}
// REMOVE THIS BRACKET
} else { // this is where i get "Syntax error on tokens, delete these tokens". it wants me to delete "} else".
System.out.println(you + " you are a looser!!!!!!!!");
}
keyboard.close();
}
}

Related

How to end the while loop with either player1 or player2 entering "Q"?

I am stuck at a part where in a game, I use while loop and to end the loop and get the results of the game, I want either "player1" or "player2" to enter "Q", and so i tried doing it like this:
if (player1.equals("Q") || player2.equals("Q")){
go = false; //go is a boolean variable
}
This doesn't seem to work as I have to enter "Q" for both player1 and player2 for the game to end, but instead I just want either of them to enter "Q" and the game would stop.
Code:
import java.util.Scanner;
public class Team {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Soccer Game Between 2 Teams");
System.out.println("Win is 2 points" + "\n" + "Loss is worth 0 points" + "\n" + "Overtime is worth 1 point");
System.out.println("Type W, O, or L" + "\n" + "Type Q to end the game");
int pointsw = 0;
int pointsl = 0;
int pointso = 0;
int pointsw2 = 0;
int pointsl2 = 0;
int pointso2 = 0;
int totalpoints = 0;
int totalpoints2 = 0;
int counter = 0;
int counter2 = 0;
boolean go = true;
System.out.println("\n" + "Enter team one:");
String phrase = keyboard.next();
System.out.println("\n" + "Enter team two:");
String phrase2 = keyboard.next();
System.out.println();
while (go) {
System.out.println("Enter " + phrase + " Result:");
String team1 = keyboard.next();
System.out.println("Enter " + phrase2 + " Result");
String team2 = keyboard.next();
if (team1.equals("W") || team1.equals("w")) {
pointsw += 2;
} else if (team1.equals("O") || team1.equals("o")) {
pointso += 1;
} else if (team1.equals("L") || team1.equals("l")) {
pointsl += 0;
}
counter++;
if (team2.equals("W") || team2.equals("w")) {
pointsw2 += 2;
} else if (team2.equals("O") || team2.equals("o")) {
pointso2 += 1;
} else if (team2.equals("L") || team2.equals("l")) {
pointsl2 += 0;
}
counter2++;
totalpoints = pointsw + pointso + pointsl;
totalpoints2 = pointsw2 + pointso2 + pointsl2;
if (team1.equals("Q") || team2.equals("Q")) {
go = false;
if (totalpoints > totalpoints2) {
System.out.println(phrase + " wins with " + totalpoints + " points");
System.out.println("It took " + phrase + " " + counter + " rounds to win");
} else if (totalpoints < totalpoints2) {
System.out.println(phrase2 + " wins with " + totalpoints2 + " points");
System.out.println("It took " + phrase2 + " " + counter2 + " rounds to win");
} else if (totalpoints == totalpoints2) {
int totalrounds = counter + counter2;
System.out.println("It is tie game between " + phrase + " and " + phrase2);
System.out.println("The game lasted till " + totalrounds + " rounds");
}
}
}
}
}
You should reorganize your code:
while (true) {
System.out.println("Enter " + phrase + " Result:");
String team1 = keyboard.next().toLowerCase();
if ("q".equals(team1)) {
break;
}
System.out.println("Enter " + phrase2 + " Result");
String team2 = keyboard.next().toLowerCase();
if ("q".equals(team2)) {
break;
}
if (team1.equals("w")) {
pointsw += 2;
} else if (team1.equals("o")) {
pointso += 1;
} else if (team1.equals("l")) {
pointsl += 0;
}
counter++;
if (team2.equals("w")) {
pointsw2 += 2;
} else if (team2.equals("o")) {
pointso2 += 1;
} else if (team2.equals("l")) {
pointsl2 += 0;
}
counter2++;
totalpoints = pointsw + pointso + pointsl;
totalpoints2 = pointsw2 + pointso2 + pointsl2;
} // loop completed
if (totalpoints > totalpoints2) {
System.out.println(phrase + " wins with " + totalpoints + " points");
System.out.println("It took " + phrase + " " + counter + " rounds to win");
} else if (totalpoints < totalpoints2) {
System.out.println(phrase2 + " wins with " + totalpoints2 + " points");
System.out.println("It took " + phrase2 + " " + counter2 + " rounds to win");
} else if (totalpoints == totalpoints2) {
int totalrounds = counter + counter2;
System.out.println("It is tie game between " + phrase + " and " + phrase2);
System.out.println("The game lasted till " + totalrounds + " rounds");
}
I'm not completely sure, but I think the issue is that after player 1 / player 2 says 'Q'
the scanner is still waiting for the next line to read.
String phrase = keyboard.next();
System.out.println("\n"+"Enter team two:");
String phrase2 = keyboard.next();//if player 1 types q this next() method must be resolved before it will continue to the logic
so add an if statement before play 2 goes asking if player 1 typed 'Q' , if so calculate scores and end game, if player 1 did not type 'Q' use else statement to continue on to player 2's turn

How do I initialize a variable in an if else program that combines three choices?

I'm writing a party planner program for a question for class.
I can't initialize my three choices of entertainment, decorations, and food.
Eclipse tells me that I should set all these values to 0. I have to stick to these if else statements because that's what we have learned so far.
Here is my code:
import java.util.Scanner;
public class PartyPlanner {
public static void main(String[] args) {
// TODO Auto-generated method stub
int entertainment;
int decorations;
int food;
int budget = entertainment + decorations + food;
Scanner keyboard = new Scanner(System.in);
System.out.println("For your choices, please type"
+ " in what is contained in the brackets."
+ " We will do the calculations for you.");
System.out.println("Choose entertainment:"
+ " [band] for $400 or " + "[DJ] for $150");
String choice1 = keyboard.nextLine();
if (choice1 == "DJ")
{
entertainment = 400;
}
else if (choice1 == "band")
{
entertainment = 150;
}
System.out.println("Where would you like to buy "
+ "decorations? [school] for $100 or [your own] for $250 ?");
String choice2 = keyboard.nextLine();
if (choice2 == "school")
{
decorations = 100;
}
else if (choice2 == "your own")
{
decorations = 250;
}
System.out.println("Would you like to purchase"
+ " [pizza] for $200 or [sub sandwiches]"
+ " for $250 or [appetizers] for $150?");
String choice3 = keyboard.nextLine();
if (choice3 == "pizza")
{
food = 200;
}
else if (choice3 == "sub sandwiches")
{
food = 250;
}
else if (choice3 == "appetizers")
{
food = 150;
}
System.out.println("You have chosen: " + choice1 +
" and " + choice2 + " and " + choice3);
System.out.println("The total cost of this party"
+ " comes out to:" + budget);
}
}
The problem is
The local variable entertainment, decorations, and food may have not been initalized.
First , you have to make the sum at the end of the code because at first the variables are not initialized yet , and secondly you can assign a value of zero if no choice have been made , like this :
public class PartyPlanner {
public static void main(String[] args) {
// TODO Auto-generated method stub
int entertainment;
int decorations;
int food;
Scanner keyboard = new Scanner(System.in);
System.out.println("For your choices, please type"
+ " in what is contained in the brackets."
+ " We will do the calculations for you.");
System.out.println("Choose entertainment:"
+ " [band] for $400 or " + "[DJ] for $150");
String choice1 = keyboard.nextLine();
if (choice1 == "DJ")
{
entertainment = 400;
}
else if (choice1 == "band")
{
entertainment = 150;
}
else { entertainment = 0; }
System.out.println("Where would you like to buy "
+ "decorations? [school] for $100 or [your own] for $250 ?");
String choice2 = keyboard.nextLine();
if (choice2 == "school")
{
decorations = 100;
}
else if (choice2 == "your own")
{
decorations = 250;
}
else { decorations = 0; }
System.out.println("Would you like to purchase"
+ " [pizza] for $200 or [sub sandwiches]"
+ " for $250 or [appetizers] for $150?");
String choice3 = keyboard.nextLine();
if (choice3 == "pizza")
{
food = 200;
}
else if (choice3 == "sub sandwiches")
{
food = 250;
}
else if (choice3 == "appetizers")
{
food = 150;
}
else { food = 0 ; }
int budget = entertainment + decorations + food;
System.out.println("You have chosen: " + choice1 +
" and " + choice2 + " and " + choice3);
System.out.println("The total cost of this party"
+ " comes out to:" + budget);
}
}

simple java multiplication game

I'm making a simple multiplication game, but when the user enters a correct answer, it still runs the else statement. I know it's a simple solution but I just can't figure it out. Can someone give me a hand?
public static void partB() {
System.out.println("Exercise 1B");
int count = 0;
String active = "true";
int correct = 0;
while (active == "true") {
Random r = new Random();
int Low = 10; //inclusive
int High = 21; //not inclusive
int Result = r.nextInt(High - Low) + Low;
Random r2 = new Random();
int Result2 = r2.nextInt(High - Low) + Low;
int Total = Result * Result2;
Scanner input = new Scanner(System.in);
System.out.println(Result + "*" + Result2 + "=?");
String guess = new String(input.nextLine());
String tostrng = String.valueOf(Total);
if (guess.equals (tostrng)) {
correct += 1;
count+=1;
System.out.println("Correct answer. Score: " + correct + "(" + count + ")");
}
if (guess.equals("q")) {
System.out.println("Good Bye!");
active = "false";
//return;
}
else {
count +=1;
System.out.println("Incorrect answer. Score:" + correct + "(" + count + ")");
}
}
}
Your else with wrong if
public static void partB() {
System.out.println("Exercise 1B");
int count = 0;
String active = "true";
int correct = 0;
while (active == "true") {
Random r = new Random();
int Low = 10; //inclusive
int High = 21; //not inclusive
int Result = r.nextInt(High - Low) + Low;
Random r2 = new Random();
int Result2 = r2.nextInt(High - Low) + Low;
int Total = Result * Result2;
Scanner input = new Scanner(System.in);
System.out.println(Result + "*" + Result2 + "=?");
String guess = new String(input.nextLine());
String tostrng = String.valueOf(Total);
if (guess.equals (tostrng)) {
correct += 1;
count+=1;
System.out.println("Correct answer. Score: " + correct + "(" + count + ")");
}
else {
count +=1;
System.out.println("Incorrect answer. Score:" + correct + "(" + count + ")");
}
if (guess.equals("q")) {
System.out.println("Good Bye!");
active = "false";
//return;
}
}
}
Make type of active variable as boolean i.e. boolean active=true;
and for comparing string values always use .equals() method.
Fixed it like this!
thanks for the help though guys.
if (guess.equals("q")) {
System.out.println("Good Bye!");
return;
}
if (guess.equals(tostrng)) {
correct += 1;
count += 1;
System.out.println("Correct answer. Score: " + correct + "(" + count + ")");
} else {
count += 1;
System.out.println("Incorrect answer. Score:" + correct + "(" + count + ")");
}

I am comparing two sets of integers in two separate arrays to match lottery numbers

I am having a problem with my loop and I realise there is probably a slight adjustment needs to be made to get this working the right way but I just cant see what that is! I have included the code below:
final int SIZE = 6;
//array to store user numbers
int [] userNumbers = new int[SIZE];
boolean found = false;
int pos = 0;
boolean bonus = false;
int lottCount = 0;
while (pos<SIZE)
{
System.out.println("enter your numbers");
userNumbers[pos]=keyboard.nextInt();
pos++;
}
for (int count: userNumbers)
{
System.out.println(count);
}
for (int loop = 0; loop <numbers.length; loop++ )
{
for (int loopOther = 0; loopOther < SIZE; loopOther++)
{
if (userNumbers[loop] == numbers[loopOther])
lottCount++;
}
if (userNumbers[loop] == bonusBall)
{
bonus = true;
System.out.println("You have matched " + lottCount + " numbers " + "and" + " the bonus ball" + bonusBall);
}
else
{
System.out.println("You have not won at this time");
}
}
System.out.println("You have matched " + lottCount + " numbers");
The ouput looks like this:
15
16
17
18
19
43
You have not won at this time
You have not won at this time
You have not won at this time
You have not won at this time
You have not won at this time
You have matched 1 numbers the bonus ball43
You have matched 1 numbers
I only want the program to inform me of each condition once. can anyone help me with this? Thanks in advance
for (int loop = 0; loop <numbers.length; loop++ )
{
for (int loopOther = 0; loopOther < SIZE; loopOther++)
{
if (userNumbers[loop] == numbers[loopOther])
lottCount++;
}
if (userNumbers[loop] == bonusBall)
{
bonus = true;
}
}
if (bonus)
{
System.out.println("You have matched " + lottCount + " numbers " + "and" + " the bonus ball" + bonusBall);
}
else
{
System.out.println("You have not won at this time");
}
Or shorter:
for (int number : numbers)
{
for (int userNumber : userNumbers)
{
if (userNumber == number)
lottCount++;
}
if (userNumber == bonusBall)
{
bonus = true;
}
}
if (bonus)
{
System.out.println("You have matched " + lottCount + " numbers " + "and" + " the bonus ball" + bonusBall);
}
else
{
System.out.println("You have not won at this time");
}

NoSuchElementException reading/ scanning input

Here is the main problem:
java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Unknown Source)
at ExamAnalysis.main(ExamAnalysis.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:271)
The program compiles and runs. It's just that I am either getting the java.util.NoSuchElementException along with my five jother errors with (answer.charAt(i) == char) near the bottom. Here is my program:
import java.io.*;
import java.util.Scanner;
class ExamAnalysis
{
public static void main(String [] args) throws FileNotFoundException
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Please type the correct answers to the exam questions, one right after the other: ");
String answers = keyboard.nextLine();
System.out.println("Where is the file with all the student responses? ");
String responses = keyboard.nextLine();
Scanner read = new Scanner(new File(responses));
while (read.hasNextLine())
{
for (int i = 0; i <= 10; i++)
{
responses = read.nextLine();
int p = 1;
p += i;
System.out.println("Student " + p + " responses: " + responses.substring(0,10));
}
System.out.println("Thank you for the data on 9 students. Here's the analysis: ");
resultsByStudents(responses, answers);
analysis(responses);
}
}
public static void resultsByStudents(String responses, String answers)
{
System.out.println ("Student # Correct Incorrect Blank");
System.out.println ("~~~~~~~~~ ~~~~~~~ ~~~~~~~~~ ~~~~~");
int student = 0;
int correct = 0;
int incorrect = 0;
int blank = 0;
for (int i = 0; i <= 9; i++)
{
for (int j = 0; j <= responses.length(); j++)
{
if ((responses.charAt(j)) == answers.charAt(j))
correct++;
else if ((responses.charAt(j)) != answers.charAt(j))
incorrect++;
else
blank++;
}
System.out.println(student + " " + correct + " " + incorrect + " " + blank);
student++;
}
}
public static void analysis(String responses)
{
System.out.println("QUESTION ANALYSIS (* marks the correct response)");
System.out.println("~~~~~~~~~~~~~~~~~");
//stores the percentage of each choice chosen
double A = 0;
double B = 0;
double C = 0;
double D = 0;
double E = 0;
double X = 0;
// tallys every variable chosen per question
for (int i = 0; i <= 10; i++) // go through all the questions
{
for (int j = 0; j <= responses.charAt(i); j++) //go through all the student responses
{
// variable that are being tallied
int chooseA = 0;
int chooseB = 0;
int chooseC = 0;
int chooseD = 0;
int chooseE = 0;
int chooseBlank = 0;
//variables take percentage of choices that have been chosen from each student
A = chooseA/9;
B = chooseB/9;
C = chooseC/9;
D = chooseD/9;
E = chooseE/9;
X = chooseBlank/9;
// variables that will print the asterisk with certain character of correct answer
String a = "A";
String b = "B";
String c = "C";
String d = "D";
String e = "E";
String blank = "blank";
if (responses.charAt(j) == A)
chooseA++;
else if (responses.charAt(j) == B)
chooseB++;
else if (responses.charAt(j) == C)
chooseC++;
else if (responses.charAt(j) == D)
chooseD++;
else if (responses.charAt(j) == E)
chooseE++;
else
chooseBlank++;
System.out.println("Question #" + i);
if (answers.charAt(i) == 'A') a = "A*"; // answers cannot be resolved(I already made it a global variable in my main method.)
else if (answers.charAt(i) == 'B') b = "B*";// answers cannot be resolved
else if (answers.charAt(i) == 'C') c = "C*";// answers cannot be resolved
else if (answers.charAt(i) == 'D') d = "D*";// answers cannot be resolved
else if (answers.charAt(i) == 'E') e = "E*";// answers cannot be resolved
System.out.println(a + " " + b + " " + c + " " + d + " " + e + " " + blank);
System.out.println (chooseA + " " + chooseB + " " + chooseC + " " + chooseD + " " + chooseE + " " + chooseBlank );
System.out.println (A + " " + B + " " + C + " " + D + " " + E + " " + X);
}
}
}
}
while (read.hasNextLine())
{
for (int i = 0; i <= 10; i++)
{
responses = read.nextLine();
int p = 1;
p += i;
System.out.println("Student " + p + " responses: " + responses.substring(0,10));
}
System.out.println("Thank you for the data on 9 students. Here's the analysis: ");
resultsByStudents(responses, answers);
analysis(responses);
}
}
Your logic here is confusing you. read.nextLine(); "Advances this scanner past the current line and returns the input that was skipped. This method returns the rest of the current line, excluding any line separator at the end. The position is set to the beginning of the next line."
So you are saying, does it have a line? If so, read the next 10...well...11 lines, which isn't what you want. You don't know if there are 11 lines past this point. Don't know what that text file looks like, but you will want to restructure this part to either say, "While it has a next line", or "Read 11 lines"
Remove the for loop may resolve the issue. You are checking only once by using while(hasNextLine() ) but calling read.nextLine() 10 times in for loop.
for (int i = 0; i <= 10; i++)
{
responses = read.nextLine();
.......
}
int i = 0;
int numberOfStudents = 9;
while (i < numberOfStudents && read.hasNextLine()){
responses = read.nextLine();
i++;
System.out.println("Student " + i + " responses: " + responses.substring(0,10));
}
System.out.println("Thank you for the data on "+ numberOfStudents +" students. Here's the analysis: ");
resultsByStudents(responses, answers);
analysis(responses);
i < numberOfStudents : makes the required number of inserts
read.hasNextLine() : checks if there is input from console. If not the program waits for input.
for (int i = 0; i <= 10; i++)
count from 0 -> 10 = 11 students

Categories