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

Can someone help me with this program please!!!!!!!! Very much appreciated. Also

ID: 3602443 • Letter: C

Question

Can someone help me with this program please!!!!!!!! Very much appreciated.

Also, I know a file needs to be placed in the program and read, but I'm unsure what to put in that file for the program to read it. Please help and thank you!

In most programming angages, the compier carries a peeprocessing step to determine if certain statements will compile. For instance it may check to see if parenheses match. Write a Java program that simulates the actions of a preprocessor, to detct if certain Java constructs are syntactically comect. Table 1 shows the types of Java statement formats under consideration, and also example of cach statement Table 1 Forrmat Statement Method Example ntx-3+(10-410+4) pablic void displagint m) data type- expression eattm> " name(cas Name pablic elass MyParser dt fields publie satie veld malgg dispay satic vold displaytint x) 252 Table 2 shoas the delimiters under cosideration. Table 2 Delimiters Symbol Lefi parenthesis Right potenthss lefi eurly braces Right curly braces Left squsne beackets Ripht square beackers Foeward slash Scar (maltiplication symbol) Note: In your implementation, design a class called Prepocessor that accepts a file that represents the prograrn to be analyzed. The class ill contain, among other possible methods, a method that determines whether or not the statement in the file are valid, with respect toedelimiters of Table 2. Do not be concerned with other symbal:s 1. 2. Yoa will need a test class. You may aant to name it MyPreprocessor. Yoa may have to enter all starements on a single line, unless you will be reading the input from a file, in which case the file would be read using presumable the class BufferedReader oe LineNumberReader. Your output would ho the stage 3. input, and say whether or not the nut assed the 4. Yoa are to use the concept of stack to determine if the constructs are syntactically correet

Explanation / Answer

import java.io.File;

importjava.io.IOException;

import java.util.Scanner;

public class SpellCheck {

public static void main(String[] args) throwsIOException {

Scanner dictionary = new Scanner(newFile(args[0]));

Scanner size = dictionary;

int numWords = 0;

while (size.hasNext()) {

numWords++;

size.next();

}

int count = 0;

String[] words = newString[numWords];

while (dictionary.hasNext()) {

words[count] =dictionary.next();

count++;

}

System.out.println("What file doyou wish to spell check? Or type quit when done.");

Scanner document = newScanner(System.in);

String w = document.next();

String [] mispelled = new String[10];

while (!w.equalsIgnoreCase("quit")){

Scanner in = newScanner(new File(w));

int j;

while (in.hasNext()){

Stringword = in.next();

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote