Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

And here is the JGRASP Java code for part 1 import java.util.Scanner; import jav

ID: 3938585 • Letter: A

Question

And here is the JGRASP Java code for part 1

import java.util.Scanner;
import java.io.File;

public class Assignment3 {
   public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.println("Please enter the word you are looking for:");
String search = input.nextLine();

File file = new File("movieReviews.txt");


try {
  
   Scanner fInput = new Scanner(file);
  
   int sum = 0;
   int counter = 0;
   double scoreAccumulator = 0;
  
  
   while (fInput.hasNextLine()) {
  
String line = fInput.nextLine();


if (line.contains(search)) {
int score = Character.getNumericValue(line.charAt(0));
   sum += score;
   counter++;
   scoreAccumulator +=
   Double.parseDouble(line.substring(0, 1));
}
   }
  
  
   double scoreAverage = 0.0;
  
   scoreAverage = scoreAccumulator / counter;

   System.out.println("The word " + search + " appears " + counter + " times");
   System.out.println("The average score is " + scoreAverage);
  
  

} catch(Exception e) { }
  
   }
  
}


Explanation / Answer

///////////////////////////////////Answer 1:

import java.util.Scanner;

import java.io.File;

public class Assignment3 {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.println("Please enter the word you are looking for:");

String search = input.nextLine();

File file = new File("movieReviews.txt");

try {

Scanner fInput = new Scanner(file);

int sum = 0;

int counter = 0;

double scoreAccumulator = 0;

double scoreAcc=0;

while (fInput.hasNextLine()) {

String line = fInput.nextLine();

double scoreAccumulator= wordScore(search) ;

}

double scoreAverage = 0.0;

  

scoreAverage = scoreAccumulator / counter;

System.out.println("The word " + search + " appears " + counter + " times");

System.out.println("The average score is " + scoreAverage);

}catch(Exception e)

{ }

public static double wordScore(String word)

{ if (line.contains(word)) {

int score = Character.getNumericValue(line.charAt(0));

sum += score;

counter++;

scoreAcc += Double.parseDouble(line.substring(0, 1));

return scoreAcc;

}

}

}

}

/////////////////////////////Answer 2,3,4,5.

import java.util.Scanner;
import java.io.File;

public class Assignment3 {
public static void main(String[] args) {

Scanner input = new Scanner(System.in);

   /**answer 2*/
System.out.println("please enter the review for the movie:");
String reviewLine[]=new String[25];
   /**end of answer 2*/

   /**answer 3*/
   for(int inc=1;inc<=25;inc++)
   {  
       reviewLine[inc]=input.nextLine();
   } /**end of answer 3*/

System.out.println("Please enter the word you are looking for:");
String search = input.nextLine();

try {
  
int sum = 0;
int counter = 0;
double scoreAccumulator = 0;
   double scoreAcc=0;

   scoreAccumulator=wordScore(search);
double scoreAverage = 0.0;
/**Answer 5*/
scoreAverage = scoreAccumulator / counter;
System.out.println("The word " + search + " appears " + counter + " times");
System.out.println("The average score is " + scoreAverage);
/**end of answer 5*/

}catch(Exception e)
{ }


/**answer 4*/
public static double wordScore(String word)
{   for(int count=0; count<=reviewLine.length-1;count++){
       String str= reviewLine[count];
       if (str==word) {
          int score = Character.getNumericValue(str.charAt(0));
            sum += score;
            counter++;
            scoreAcc += Double.parseDouble(str.substring(0, 1));
           return scoreAcc;
       }
   }
}
/**end of answer 4*/

}
  
}