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

I have 45 mins to finish this. here is where I\'m at... any help would be apprec

ID: 3681744 • Letter: I

Question

I have 45 mins to finish this. here is where I'm at... any help would be appreciated. This is my second post :(

package project1;

import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;

public class Main {
   public static void main(String[] pArgs) {
      
       Main mainObject = new Main();
       mainObject.run();
   }
      
   private void run() {
      
       ArrayList<Integer> list = new ArrayList<Integer>();
      
       try {
           Scanner scan = new Scanner(new File("src/project1/p01-in.txt"));
           while (scan.hasNextInt()){
       list.add(scan.nextInt());}
           scan.close(); }
       catch (FileNotFoundException e) {
           e.printStackTrace();}
      
       ArrayList<Integer> listRunsUpCount = new ArrayList<Integer>();
       ArrayList<Integer> listRunsDnCount = new ArrayList<Integer>();
//       listRunsUpCount ? FindRuns(list, RUNS_UP)
//       listRunsUpCount ? FindRuns(list, RUNS_DN)
       ArrayList<Integer> listRunsCount = new ArrayList<Integer>();  
//       listRunsCount ? Merge(listRunsUpCount, listRunsDnCount)
//       Output("p01-runs.txt", listRunsCount)
   }
       Method FindRuns(ArrayList<Integers> pList, int pDir){
//           Returns ArrayList of Integers
//           listRunsCount ? arrayListCreate(pList.size(), 0)
           int i = 0;
           int k = 0;
           While (i < pList.size()){
               if(){ //If pDir is RUNS_UP and pList element at i is ? pList element at i + 1
                   k++;
               }
               else if (){ //ElseIf pDir is RUNS_DN and pList element at i is ? pList element at i + 1
                   k++;
               }
               else {
                   if(k !=0){
                       //Increment the element at index k of listRunsCount
                       k = 0;
                   }
               i++;
           }
      
       if (k != 0){
           //Increment the element at index k of listRunsCount
       }
      
       return listRunsCount;
       }
          
       Method Merge(pListRunsUpCount, pListRunsDnCount){
           Returns ArrayList of Integers
       listRunsCount ? arrayListCreate(pListRunsUpCount.size(), 0)
       for (i = 0; i < pListRunsUpCount.size(); i++){
               listRunsCount[i] = to the sum of the elements at i in pListRunsUpCount and pListRunsDnCount
       }
       return listRunsCount;
       }
       Method arrayListCreate(int pSize; int pInitValue){
           Returns ArrayList of Integers
      
           ArrayList<Integer> list = new ArrayList<Integer>();
           for(i = 0; i < pSize; i++){
               add(pInitValue) to list
           }
       return list;
       }
      
       void Output(pFilename; ArrayList<Integer> pListRuns ){
           try {
           Scanner scan = new Scanner(new File("src/project1/p01-out.txt"));}
       catch (FileNotFoundException e) {
           e.printStackTrace();}}
       out.print("runs_total, ", the sum of pListRuns)
      
       for (k = 1; k < pListRuns.size()){
  
       out.print("runs_k, ", the element at index k of pListRuns)
       }
       out.close();
       }
      
      
   }


Let list be a nonempty sequence of nonnegative random integers, each in the range [o, 32767] and le: n be the length of list, e-g list = { 2, 8, 3, 2, 9, 8, 6, 3, 4, 6, 1,9) where n = 12. List elements are numbered starting at 0, we define a run up to be a (A+1)-length subsequence list isa ist,list, that is monotonically increasing (ie., list 2 list j for each j-1,2, 3, .., k). Similarly, a run down is a (k+1)-length subsequence list, list, lists, st, that is monotonically decreasing Le., slist) for each -1, 2, 3 For the above example list we have these runs up and runs down Runs Up Runs 1 listo through list 2, 8): lists list, through list.-{8,3,2):k=2 tis4 through tis -(9, 8, 6, 3 }; k=3 liste list, through lists _ {6,1); k=1 lists through lists (2, 9) k-1 lists lists- list through list 3, 4, 6): -2 ist" through ist,-{1,9):k-1 We are interested in the value of k for each run up and run down and in particular we are interested in the total umber of runs tor each nonzero k, which we shall denote by rans, 0

Explanation / Answer

word count problem in java

public class WordCounterProblem{ /* * This method return word count without using regular expression */ public int wordcount(String word) { if (word == null || word.isEmpty()) { return 0; } int count = 0; char ch[] = new char[word.length()]; for (int i = 0; i < word.length(); i++) { ch[i] = word.charAt(i); if (((i > 0) && (ch[i] != ' ') && (ch[i - 1] == ' ')) || ((ch[0] != ' ') && (i == 0))) { count++; } } returncount; } /* * Counting number of words using regular expression. */ public int countWord(String word) { if (word == null) { return 0; } String input = word.trim(); int count = input.isEmpty() ? 0 : input.split("\s+").length; return count; } }