Question

Correct answer for this Java problem will get thumbs up and eternal thanks

Problem Description

Over the course of this semester you will write a chess game database that will import chess games in PGN (http://www.saremba.de/chessgml/standards/pgn/pgn- complete.htm) format. As a first step you will write code to read PGN games and resolve board positions.

Solution Description

Write a class called PgnReader that contains the following public static methods:

tagValue takes two String arguments: a tag name and a String which contains a PGN-formatted game, and returns a String containing the value from the tag name tag pair in the PGN game text. If there is no tag name tag pair, return "NOT GIVEN" .
finalPosition takes a single String argument which contains a PGN-formatted game and returns a String containing the game’s final position in Forsyth-

Edwards Notation (FEN (http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm#c16.1)).

Write a main method that reads the file named in the PgnReader ’s first command-line argument into a String and uses that String as the argument to each method above in order to print game information to the console. First, print the tag names and associated values for the core seven tags of the PGN standard: Event, Site, Date, Round, White, Black, Result. Then print a line reading “Final Position:” and a line displaying the final game position in FEN. Note that in this assignment we only care about the piece placement data, not the other elements of FEN such as active color or castling availability.

Each PGN file will contain a single game and you may assume that the PGN files are valid, and the move text contains only moves, no annotation text. Moves may end in check symbols (‘+’) or strength judgements (‘!’, ‘?’).

As your program reads the moves in a game it will need to maintain the state of the board, which you should store in a 2-d array. You will also need to translate between the algebraic notation used to represent moves in PGN, and the internal representation you use for board state, e.g., array indices.

You may use this skeleton file which contains a completed main method and code to read a file and return its content as a String : PgnReader.java. This skeleton file also contains stubbed tagValue and finalPosition methods. A stubbed method is a method that returns a dummy type-correct value (if applicable) so that you can successfully compile code that uses the method. Stubbed methods are useful in incremental program development. You will want to write many helper methods.

Using the fegatello.pgn (/fall2017/hw1/fegatello.pgn), a shell session with your program would look like this: $ java PgnReader fegatello.pgn Event: Fegatello Attack Site: NOT GIVEN Date: NOT GIVEN Round: NOT GIVEN White: NOT GIVEN Black: NOT GIVEN Result: NOT GIVEN Final Position: r1bqkb1r/ppp2Npp/2n5/3np3/2B5/8/PPPP1PPP/RNBOK2R Domain Knowledge You dont need to know how to play chess, you only need to know how the pieces and pawns move and how to record chess moves. Use the following links for this purpose: Learn to Play Chess (http://www.chesscorner.com/tutorial/learn.htm) - You only need to read the information under Rules of Chess. Chess Notation (http://www.chesscorner.com/tutorial/basic/notation/notate.htm) look at abbreviated algebraic notation. And, of course, you need to know the PGN Standard (http://www.saremba.de/chessgm/standards/pgn/pgn-complete.htm). You only need sections 2.3, 8.1-8.2.3.6, 16.1.3.1 and 16.1.4. PGN is simple, and you can learn it well enough by simply looking at example PGN games.

Grading

There are 20 bonus points on this assignment.

50 points for correctly extracting tag values.
10 points for correctly finding final position of simple games or openings , scholars-mate.pgn
10 points for correctly finding final position of games that contain castling moves
10 points for correctly finding final position of games that contain pawn promotions
10 points for correctly finding final position of games that contain en passant pawn captures
10 points for correctly finding final position of games that contain moves requiring disambiguation of starting file or rank (but not both) to distinguish between two pieces that could make the same move
10 points for correctly finding final position of games that contain moves requiring disambiguation of starting file and rank to distinguish between two pieces that could make the same move
10 points for correctly finding final position of games that require knowledge of tactics (e.g., pinned pieces) to disambiguate to distinguish between two pieces that could make the same move

---------------------------------------------------------------------------------------Necessary files---------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------PgnReader.java---------------------------------------------------------------------------------------

import java.io.BufferedReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class PgnReader {

    /**
     * Find the tagName tag pair in a PGN game and return its value.
     *
     * @see http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm
     *
     * @param tagName the name of the tag whose value you want
     * @param game a `String` containing the PGN text of a chess game
     * @return the value in the named tag pair
     */
    public static String tagValue(String tagName, String game) {
        return "NOT GIVEN";
    }

    /**
     * Play out the moves in game and return a String with the game's
     * final position in Forsyth-Edwards Notation (FEN).
     *
     * @see http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm#c16.1
     *
     * @param game a `Strring` containing a PGN-formatted chess game or opening
     * @return the game's final position in FEN.
     */
    public static String finalPosition(String game) {
        return "";
    }

    /**
     * Reads the file named by path and returns its content as a String.
     *
     * @param path the relative or abolute path of the file to read
     * @return a String containing the content of the file
     */
    public static String fileContent(String path) {
        Path file = Paths.get(path);
        StringBuilder sb = new StringBuilder();
        try (BufferedReader reader = Files.newBufferedReader(file)) {
            String line = null;
            while ((line = reader.readLine()) != null) {
                // Add the \n that's removed by readline()
                sb.append(line + "\n");
            }
        } catch (IOException e) {
            System.err.format("IOException: %s%n", e);
            System.exit(1);
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        String game = fileContent(args[0]);
        System.out.format("Event: %s%n", tagValue("Event", game));
        System.out.format("Site: %s%n", tagValue("Site", game));
        System.out.format("Date: %s%n", tagValue("Date", game));
        System.out.format("Round: %s%n", tagValue("Round", game));
        System.out.format("White: %s%n", tagValue("White", game));
        System.out.format("Black: %s%n", tagValue("Black", game));
        System.out.format("Result: %s%n", tagValue("Result", game));
        System.out.println("Final Position:");
        System.out.println(finalPosition(game));

    }
}

---------------------------------------------------------------------------------------fegatello.pgn---------------------------------------------------------------------------------------

[Event "Fegatello Attack"]

1. e4 e5 2. Nf3 Nc6 3. Bc4 Nf6 4. Ng5 d5 5. exd5 Nxd5 6. Nxf7

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.io.BufferedReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;

public class PgnReader {

    /**
     * Find the tagName tag pair in a PGN game and return its value.
     */
    public static String tagValue(String tagName, String game) {
        int index = game.indexOf(tagName);
        String value = "NOT GIVEN";
        if (index != -1) {
            index = index + tagName.length() + 2;

            value = "";
            char cur = game.charAt(index);
            while (cur != '"')
            {
                value += cur;
                cur = game.charAt(++index);
            }
        }
        return value;
    }

    /**
     * Play out the moves in game and return a String with the game's
     * final position in Forsyth-Edwards Notation (FEN).
     */
    public static String finalPosition(String game) {
        String[][] chessBoard = initializeBoard();

        String[] split = game.split("\n");
        String move = "";
        boolean startOfMove = false;
        for(int n = 0; n < split.length; n++)
        {
            if (startOfMove)
            {
                move += split[n] + " ";
            }
            if (split[n].isEmpty())
            {
                startOfMove = true;
            }
        }
        move = move.substring(0,move.length() - 1);

        int index = 1;
        String stage = Integer.toString(index)+ ".";
        int start = move.indexOf(stage);

        while(start != -1)
        {
            int end = move.indexOf(Integer.toString(index + 1)+ ".");

            String cur;
            if (end == -1)
            {
                end = move.length();
            }

            cur = move.substring(start + stage.length(), end).trim();

            String[] whiteNblack = cur.split(" ");
            String white = whiteNblack[0];
            String black = "";
            if (whiteNblack.length == 2)
            {
                black = whiteNblack[1];
            }

            findAndMove(white, chessBoard, true);
            findAndMove(black, chessBoard, false);

            printBoard(chessBoard);

            System.out.println("-------------------------");

            index++;
            stage = Integer.toString(index)+ ".";
            start = move.indexOf(stage);
        }

        String answer = "";
        for(int i = 0; i < 8; i++)
        {
            int counter = 0;
            for(int j = 0; j < 8; j++)
            {
                String temp = chessBoard[i][j].substring(1,2);
                if (temp.equals(" "))
                {
                    counter++;
                }
                else if (counter != 0)
                {
                    answer += Integer.toString(counter) + temp;
                    counter = 0;
                }
                else
                {
                    answer += temp;
                }
            }
            if (counter != 0)
            {
                answer += Integer.toString(counter);
            }
            answer += "/";
        }
        return answer.substring(0,answer.length()-1);
    }

    private static String[][] initializeBoard()
    {
        String[][] chessBoard = {{"[r]","[n]","[b]","[q]","[k]","[b]","[n]","[r]"},
                {"[p]","[p]","[p]","[p]","[p]","[p]","[p]","[p]"},
                {"[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]"},
                {"[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]"},
                {"[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]"},
                {"[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]"},
                {"[P]","[P]","[P]","[P]","[P]","[P]","[P]","[P]"},
                {"[R]","[N]","[B]","[Q]","[K]","[B]","[N]","[R]"}};

        printBoard(chessBoard);
        return chessBoard;
    }

    private static int getJ(String file)
    {
        switch(file)
        {
            case "a": return 0;
            case "b": return 1;
            case "c": return 2;
            case "d": return 3;
            case "e": return 4;
            case "f": return 5;
            case "g": return 6;
            case "h": return 7;
            default: return -1;
        }
    }

    private static int getI(String rank)
    {
        return 8 - Integer.parseInt(rank);
    }

    private static void findAndMove(String move, String[][] chessBoard, boolean white)
    {
        if (!move.isEmpty())
        {
            String piece = move.substring(0,1);
            boolean promote = move.contains("=");

            String ifPawnOrCastle = move;
            String[] caught = move.split("x");
            if (caught.length == 2)
            {
                move = caught[1];
            }
            else
            {
                move = move.substring(1,move.length());
            }
            String moveFrom = null;
            switch(piece)
            {
                case "R": moveFrom = findRook(move, chessBoard, white); break;
                case "N": moveFrom = findKnight(move, chessBoard, white); break;
                case "B": moveFrom = findBishop(move, chessBoard, white); break;
                case "Q": moveFrom = findQueen(move, chessBoard, white); break;
                case "K": moveFrom = findKing(move, chessBoard, white); break;
                case "O": Castle(ifPawnOrCastle, chessBoard, white); break;
                default: break;
            }

            System.out.println(white + ": the piece is " + piece + " and it's at " + moveFrom);

            if (moveFrom == null && !piece.equals("O"))
            {
                moveFrom = findPawn(ifPawnOrCastle, chessBoard, white);
                movePiece(ifPawnOrCastle, chessBoard, moveFrom, promote);
            }
            else if(moveFrom != null)
            {
                movePiece(move, chessBoard, moveFrom);
            }
        }
    }

    private static String findPawn(String move, String[][] chessBoard, boolean white)
    {
        String answer = "";
        String compareTo = "[p]";
        if (white) {
            compareTo = compareTo.toUpperCase();
        }

        String[] split = move.split("x");

        int j = getJ(move.substring(0,1));
        for(int i = 1; i < 7; i++)
        {
            if(chessBoard[i][j].equals(compareTo))
            {
                if(split.length == 2)
                {
                    int destI = getI(split[1].substring(1,2));
                    int destJ = getJ(split[1].substring(0,1));

                    if (Math.abs(destI - i) == 1 && Math.abs(destJ - j) == 1)
                    {
                        answer = i + "," + j;
                    }
                }
                else
                {
                    int destI = getI(split[0].substring(1,2));
                    int destJ = getJ(split[0].substring(0,1));

                    if ((white && i == 6) || (!white && i == 1))
                    {
                        if (Math.abs(destI - i) <= 2)
                        {
                            answer = i + "," + j;
                        }
                    }
                    else if (Math.abs(destI - i) == 1)
                    {
                        answer = i + "," + j;
                    }
                }
            }
        }

        return answer;
    }

    private static String findRook(String move, String[][] chessBoard, boolean white)
    {
        return findRook(move, chessBoard, white, false);
    }

    private static String findRook(String move, String[][] chessBoard, boolean white, boolean queen)
    {
        String answer = "";
        String compareTo = "[r]";
        if (queen)
        {
            compareTo = "[q]";
        }
        String empty = "[ ]";
        if (white) {
            compareTo = compareTo.toUpperCase();
        }
        int destJ = getJ(move.substring(0,1));
        int destI = getI(move.substring(1,2));

        // check above
        for (int i = destI - 1; i >= 0; i--)
        {
            if(chessBoard[i][destJ].equals(compareTo))
            {
                answer = i + "," + destJ;
            }
            else if(!chessBoard[i][destJ].equals(empty))
            {
                i = -1;
            }
        }

        // check down
        for (int i = destI + 1; i < 8; i++)
        {
            if(chessBoard[i][destJ].equals(compareTo))
            {
                answer = i + "," + destJ;
            }
            else if(!chessBoard[i][destJ].equals(empty))
            {
                i = 8;
            }
        }

        // check left
        for (int j = destJ - 1; j >= 0; j--)
        {
            if(chessBoard[destI][j].equals(compareTo))
            {
                answer = destI + "," + j;
            }
            else if(!chessBoard[destI][j].equals(empty))
            {
                j = -1;
            }
        }

        // check right
        for (int j = destJ + 1; j < 8; j++)
        {
            if(chessBoard[destI][j].equals(compareTo))
            {
                answer = destI + "," + j;
            }
            else if(!chessBoard[destI][j].equals(empty))
            {
                j = 8;
            }
        }

        return answer;
    }

    private static String findKnight(String move, String[][] chessBoard, boolean white)
    {
        String answer = "";
        String compareTo = "[n]";
        if (white) {
            compareTo = compareTo.toUpperCase();
        }
        int j = getJ(move.substring(0,1));
        int i = getI(move.substring(1,2));

        int[] ranks = { -2, -1, 2, 1};
        int[] files = { -2, -1, 2, 1};
        for(int k = 0; k < ranks.length; k++)
        {
            for(int l = 0; l < files.length; l++)
            {
                if(Math.abs(ranks[k]) + Math.abs(files[l]) == 3)
                {
                    int newI = i + ranks[k];
                    int newJ = j + files[l];
                    if (newI < 8 && newJ < 8 && newI >= 0 && newJ >= 0 && chessBoard[newI][newJ].equals(compareTo))
                    {
                        answer = newI + "," + newJ;
                        k = ranks.length;
                        l = files.length;
                    }
                }
            }
        }
        return answer;
    }

    private static String findBishop(String move, String[][] chessBoard, boolean white)
    {
        return findBishop(move, chessBoard, white, false);
    }

    private static String findBishop(String move, String[][] chessBoard, boolean white, boolean queen)
    {
        String answer = "";
        String compareTo = "[b]";
        if (queen)
        {
            compareTo = "[q]";
        }
        String empty = "[ ]";
        if (white) {
            compareTo = compareTo.toUpperCase();
        }
        int destJ = getJ(move.substring(0,1));
        int destI = getI(move.substring(1,2));

        // check top-left
        boolean found = false;
        int i = destI - 1;
        int j = destJ - 1;
        while (!found && i >= 0 && j >= 0)
        {
            if(chessBoard[i][j].equals(compareTo))
            {
                answer = i + "," + j;
                found = true;
            }
            else if(!chessBoard[i][j].equals(empty))
            {
                found = true;
            }
            i--;
            j--;
        }

        // check bottom-left
        found = false;
        i = destI + 1;
        j = destJ - 1;
        while (!found && i < 8 && j >= 0)
        {
            if(chessBoard[i][j].equals(compareTo))
            {
                answer = i + "," + j;
                found = true;
            }
            else if(!chessBoard[i][j].equals(empty))
            {
                found = true;
            }
            i++;
            j--;
        }

        // check top-right
        found = false;
        i = destI - 1;
        j = destJ + 1;
        while (!found && i >= 0 && j < 8)
        {
            if(chessBoard[i][j].equals(compareTo))
            {
                answer = i + "," + j;
                found = true;
            }
            else if(!chessBoard[i][j].equals(empty))
            {
                found = true;
            }
            i--;
            j++;
        }

        // check bottom-right
        found = false;
        i = destI + 1;
        j = destJ + 1;
        while (!found && i < 8 && j < 8)
        {
            if(chessBoard[i][j].equals(compareTo))
            {
                answer = i + "," + j;
                found = true;
            }
            else if(!chessBoard[i][j].equals(empty))
            {
                found = true;
            }
            i++;
            j++;
        }

        return answer;
    }

    private static String findQueen(String move, String[][] chessBoard, boolean white)
    {
        String answer = findRook(move, chessBoard, white, true);
        if (answer.isEmpty())
        {
            answer = findBishop(move, chessBoard, white, true);
        }
        return answer;
    }

    private static String findKing(String move, String[][] chessBoard, boolean white)
    {
        String answer = "";
        String compareTo = "[k]";
        String empty = "[ ]";
        if (white) {
            compareTo = compareTo.toUpperCase();
        }
        int destJ = getJ(move.substring(0,1));
        int destI = getI(move.substring(1,2));

        int[] ranks = { 0, 1, -1};
        int[] files = { 0, 1, -1};

        for(int r = 0; r < ranks.length; r++)
        {
            int i = destI + ranks[r];
            for(int f = 0; f < files.length; f++)
            {
                int j = destJ + files[f];
                if (chessBoard[i][j].equals(compareTo))
                {
                    answer = i + "," + j;
                    r = ranks.length;
                    f = files.length;
                }
            }
        }

        return answer;
    }

    private static void Castle(String move, String[][] chessBoard, boolean white)
    {
        int kingJ = 4;
        int i = 0;
        if (white)
        {
            i = 7;
        }

        int rookJ = 0;
        if (move.equals("O-O"))
        {
            rookJ = 7;

            chessBoard[i][kingJ+2] = chessBoard[i][kingJ];
            chessBoard[i][kingJ] = "[ ]";
            chessBoard[i][kingJ+1] = chessBoard[i][rookJ];
            chessBoard[i][rookJ] = "[ ]";
        }
        else {
            chessBoard[i][kingJ-2] = chessBoard[i][kingJ];
            chessBoard[i][kingJ] = "[ ]";
            chessBoard[i][kingJ-1] = chessBoard[i][rookJ];
            chessBoard[i][rookJ] = "[ ]";
        }
    }

    private static void movePiece(String move, String[][] chessBoard, String currentState)
    {
        movePiece(move, chessBoard, currentState, false);
    }

    private static void movePiece(String move, String[][] chessBoard, String currentState, boolean promote)
    {
        if (currentState.isEmpty())
        {
            return;
        }

        String[] split = move.split("x");
        String moveTo = split[split.length - 1];
        int i = getI(moveTo.substring(1,2));
        int j = getJ(moveTo.substring(0,1));

        String[] cur = currentState.split(",");
        int curI = Integer.parseInt(cur[0]);
        int curJ = Integer.parseInt(cur[1]);

        if (promote)
        {
            int promoteInt = move.indexOf("=");
            String promoteTo = move.substring(promoteInt + 1, promoteInt + 2);
            chessBoard[i][j] = "[" + promoteTo + "]";
        }
        else
        {
            System.out.println("move from (" + curI + "," + curJ + ") to (" + i + "," + j + ")");
            chessBoard[i][j] = chessBoard[curI][curJ];
        }
        chessBoard[curI][curJ] = "[ ]";
    }

    /**
     * Reads the file named by path and returns its content as a String.
     */
    public static String fileContent(String path) {
        Path file = Paths.get(path);
        StringBuilder sb = new StringBuilder();
        try (BufferedReader reader = Files.newBufferedReader(file)) {
            String line = null;
            while ((line = reader.readLine()) != null) {
                // Add the \n that's removed by readline()
                sb.append(line + "\n");
            }
        } catch (IOException e) {
            System.err.format("IOException: %s%n", e);
            System.exit(1);
        }
        return sb.toString();
    }

    private static void printBoard(String[][] chessBoard)
    {
        for(int i = 0; i < 8; i++)
        {
            for(int j = 0; j < 8; j++)
            {
                System.out.print(chessBoard[i][j]);
            }
            System.out.println();
        }
    }

    public static void main(String[] args) {
        String game = fileContent("fegatello.pgn");//filepath
        System.out.format("Event: %s%n", tagValue("Event", game));
        System.out.format("Site: %s%n", tagValue("Site", game));
        System.out.format("Date: %s%n", tagValue("Date", game));
        System.out.format("Round: %s%n", tagValue("Round", game));
        System.out.format("White: %s%n", tagValue("White", game));
        System.out.format("Black: %s%n", tagValue("Black", game));
        System.out.format("Result: %s%n", tagValue("Result", game));
        System.out.println("Final Position:");
        System.out.println(finalPosition(game));

    }
}

Add a comment
Know the answer?
Add Answer to:
Correct answer for this Java problem will get thumbs up and eternal thanks Problem Description Over...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java Help, Will definitely give a thumbs up if it works. Declare a class ComboLock that...

    Java Help, Will definitely give a thumbs up if it works. Declare a class ComboLock that works like the combination lock in a gym locker (Consult the API provided to look for the methods needed). The locker is constructed with a combination - three numbers between 0 and 39. The reset method resets the dial so that it points to 0. The turnLeft and turnRight methods turn the dial by a given number of ticks to the left or right....

  • Write in JAVA Get Familiar with the Problem Carefully read the program description and look at...

    Write in JAVA Get Familiar with the Problem Carefully read the program description and look at the data file to gain an understanding of what is to be done. Make sure you are clear on what is to be calculated and how. That is, study the file and program description and ponder! Think! The Storm Class Type Now concentrate on the Storm class that we define to hold the summary information for one storm. First, look at the definition of...

  • I need help writing this code for java class. Starter file: Project3.java and input file: dictionary.txt...

    I need help writing this code for java class. Starter file: Project3.java and input file: dictionary.txt Project#3 is an extension of the concepts and tasks of Lab#3. You will again read the dictionary file and resize the array as needed to store the words. Project#3 will require you to update a frequency counter of word lengths every time a word is read from the dictionary into the wordList. When your program is finished this histogram array will contain the following:...

  • Must be done in Java. PROBLEM 2 INFORMATION AND THE CODE PROVIDED WITH IT AS WELL....

    Must be done in Java. PROBLEM 2 INFORMATION AND THE CODE PROVIDED WITH IT AS WELL. PROBLEM 1 INFORMATION IF YOU NEED IT AS WELL: Provide the rest of the code with full comments and explanation and with proper indentation. Use simple methods for better understanding. Must compile. At the end, show the exact Output that's shown in Problem3. CODE PROVIDED FOR PROBLEM 2: import java.util.Scanner; public class Problem2 { public static void main( String [] args ) { //N...

  • For this lab you will write a Java program that plays a simple Guess The Word...

    For this lab you will write a Java program that plays a simple Guess The Word game. The program will prompt the user to enter the name of a file containing a list of words. These words mustbe stored in an ArrayList, and the program will not know how many words are in the file before it starts putting them in the list. When all of the words have been read from the file, the program randomly chooses one word...

  • You will need to think about problem solving. There are several multi-step activities. Design, compile and...

    You will need to think about problem solving. There are several multi-step activities. Design, compile and run a single Java program, StringEx.java, to accomplish all of the following tasks. Add one part at a time and test before trying the next one. The program can just include a main method, or it is neater to split things into separate methods (all static void, with names like showLength, sentenceType, lastFirst1, lastFirst), and have main call all the ones you have written...

  • Must be done in Java. PROBLEM 1 INFORMATION AND THE CODE PROVIDED WITH IT AS WELL....

    Must be done in Java. PROBLEM 1 INFORMATION AND THE CODE PROVIDED WITH IT AS WELL. Provide the rest of the code with full comments and explanation and with proper indentation. Use simple methods for better understanding. Must compile. At the end show the exact Output that's shown in the Problem 2. CODE PROVIDED FOR PROBLEM 1: import java.util.Scanner; public class Problem1 {    public static void main( String [] args )    {        //N denoting the size of the board        int...

  • Must be done in Java. PROBLEM 1 INFORMATION AND THE CODE PROVIDED WITH IT AS WELL....

    Must be done in Java. PROBLEM 1 INFORMATION AND THE CODE PROVIDED WITH IT AS WELL. Provide the rest of the code with full comments and explanation and with proper indentation. Use simple methods for better understanding. Must compile. At the end, show the exact Output that's shown in Problem 2. CODE PROVIDED FOR PROBLEM 1: import java.util.Scanner; public class Problem1 {    public static void main( String [] args )    {        //N denoting the size of the board        int n;       ...

  • Programming Assignment Objective Write a Java program that utilizes multiple classes. Write a Java program that...

    Programming Assignment Objective Write a Java program that utilizes multiple classes. Write a Java program that utilizes inheritance in a practical manner. Problem: Quiz Bowl Your high school quiz bowl team has been losing its edge and needs to find a method to improve. Knowing that you are a savvy programmer, your coach asks you to write a program that the team members can use to hone their skills. Quiz Bowl questions come in three varieties: True/False Multiple Choice (variable...

  • You will be writing a simple Java program that implements an ancient form of encryption known...

    You will be writing a simple Java program that implements an ancient form of encryption known as a substitution cipher or a Caesar cipher (after Julius Caesar, who reportedly used it to send messages to his armies) or a shift cipher. In a Caesar cipher, the letters in a message are replaced by the letters of a "shifted" alphabet. So for example if we had a shift of 3 we might have the following replacements: Original alphabet: A B C...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT