1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Vlad1618 [11]
3 years ago
14

Write a program that demonstrates the skills we've learned throughout this quarter. This type of project offers only a few guide

lines, allowing you to invest as much time and polish as you want, as long as you meet the program requirements described below. You can write a simple game (e.g., tic-tac-toe, Battleship), a simulation (e.g., a zero-dimensional energy balance model of the climate), or an application (e.g., a mortgage calculator). Your main requirement is that you demonstrate six of the following features in your software program and that you comment and document your code well:
Computers and Technology
1 answer:
UNO [17]3 years ago
5 0

This type of project offers only a few guidelines, allowing you to invest as much time and polish as you want, as long as you meet the program requirements described below.

The code given below is tic-tac-toe

Explanation:

import java.util.Arrays;

import java.util.InputMismatchException;

import java.util.Scanner;

public class TicTacToe {

static Scanner in;

static String [ ] board;

static String turn;

public static void main(String[] args) {

 in = new Scanner(System.in);

 board = new String[9];

 turn = "X";

 String winner = null;

 populateEmptyBoard();

 System.out.println("Welcome to 2 Player Tic Tac Toe.");

 System.out.println("");

 printBoard();

 System.out.println("X's will play first. Enter a slot number to place X in:");

while (winner == null) {

  int numInput;

  try {

   numInput = in.nextInt();

   if (!(numInput > 0 && numInput <= 9)) {

    System.out.println("Invalid input; re-enter slot number:");

    continue;

   }

  } catch (InputMismatchException e) {

   System.out.println("Invalid input; re-enter slot number:");

   continue;

  }

  if (board[numInput-1].equals(String.valueOf(numInput))) {

   board[numInput-1] = turn;

   if (turn.equals("X")) {

    turn = "O";

   } else {

    turn = "X";

   }

   printBoard();

   winner = checkWinner();

  } else {

   System.out.println("Slot already taken; re-enter slot number:");

   continue;

  }

 }

 if (winner.equalsIgnoreCase("draw")) {

  System.out.println("It's a draw! Thanks for playing.");

 } else {

  System.out.println("Congratulations! " + winner + "'s have won! Thanks for playing.");

 }

}

static String checkWinner() {

 for (int a = 0; a < 8; a++) {

  String line = null;

  switch (a) {

  case 0:

   line = board[0] + board[1] + board[2];

   break;

  case 1:

   line = board[3] + board[4] + board[5];

   break;

  case 2:

   line = board[6] + board[7] + board[8];

   break;

  case 3:

   line = board[0] + board[3] + board[6];

   break;

  case 4:

   line = board[1] + board[4] + board[7];

   break;

  case 5:

   line = board[2] + board[5] + board[8];

   break;

  case 6:

   line = board[0] + board[4] + board[8];

   break;

  case 7:

   line = board[2] + board[4] + board[6];

   break;

  }

  if (line.equals("XXX")) {

   return "X";

  } else if (line.equals("OOO")) {

   return "O";

  }

 }

 for (int a = 0; a < 9; a++) {

  if (Arrays.asList(board).contains(String.valueOf(a+1))) {

   break;

  }

  else if (a == 8) return "draw";

 }

 System.out.println(turn + "'s turn; enter a slot number to place " + turn + " in:");

 return null;

}

static void printBoard() {

 System.out.println("/---|---|---\\");

 System.out.println("| " + board[0] + " | " + board[1] + " | " + board[2] + " |");

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

 System.out.println("| " + board[3] + " | " + board[4] + " | " + board[5] + " |");

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

 System.out.println("| " + board[6] + " | " + board[7] + " | " + board[8] + " |");

 System.out.println("/---|---|---\\");

}

static void populateEmptyBoard() {

 for (int a = 0; a < 9; a++) {

  board[a] = String.valueOf(a+1);

 }

}

}

You might be interested in
Which tools is used to bundle cables neatly inside and outside of a computer?​
Ugo [173]

Answer:

Cable Ties

Explanation:

6 0
3 years ago
Put these operating systems in order according to the date they were released. (The first to be released would be
uysha [10]
1. ms-dos 1981
2. windows 2.0 1987
3. windows xp 2001
4. mac os 2001
5. windows 7 2009
8 0
3 years ago
Good day Statistical Methods tutor , I would like to know the formula for calculating the percentage of stockouts for the given
sveticcg [70]

In order to derive the probability of stock outs, divide the total value of the stock outs by the number of requests demanded. The resulting figure must then be multiplied by 100.

<h3>What is a stock out?</h3>

In business, a stock out refers to a condition where in a certain item or items are no longer available in stock.

The formula can be sated simply as:

Probability of Stock outs = (No of stock outs/ number of demand requests) x 100

Thus Number of Stock outs = Total probability of stock outs * total number of demand requests.

<h3>What is the formula for the Total Cost?</h3>

The formula for Total Cost is given as:

Total Fixed Cost + Total Variable Cost;

TC = TFC + TVC

Learn more about stock outs at:
brainly.com/question/16209393
#SPJ1

5 0
2 years ago
Students can use eNotes to type notes directly on screen and
zalisa [80]
A. review or print them later
6 0
3 years ago
Read 2 more answers
We have an internal webserver, used only for testing purposes, at IP address 5.6.7.8 on our internal corporate network. The pack
lukranit [14]

Answer:

Check the explanation

Explanation:

A packet filter firewall is used as a check point between internal corporate network to the outside internet. It blocks all the inbound traffic from the outside hosts trying to initiate a direct TCP connection to the internal corporate webserver. The network design with firewall is shown in the attached image below:

The figures in the attached image below shows an internal corporate network is protected with a packet filter firewall to minimize the inbound traffic from the external network or an internet. Therefore, the packet filter is used as a check point between the network.

The packet filter blocks all attempts by the outside hosts in order to initiate a direct TCP connection to the internal webserver of the internal corporate network.

Going by the second part of the attached image below can can therefore conclude that:

• Rule 1 specifies that, deny any packet with the destination address 5.6.7.8 if the STN flag of TCP header is set.

• Rule 2 specifies that, allow the inbound email traffic from the external source.

• Rule 3 specifies, allows the Outbound TCP traffic from the internal corporate network.

• Rule 4 specifies, allows outbound Email traffic from the internal corporate network to the external network.

• Rule 5 specifies, block any traffic from any source to the any destination.

3 0
3 years ago
Other questions:
  • A trench is a narrow excavation in which the depth is greater than the width and the width does not exceed 15 feet. A. False B.
    13·2 answers
  • The ____ refers to a world where everyday physical objects are connected to, and uniquely identifiable on, the Internet so they
    6·1 answer
  • Which of the following operating systems is able to join a domain a) Microsoft office pro b) Microsoft surface R.T. c) google an
    9·2 answers
  • What is the Most popular game out today?
    6·2 answers
  • There is the Iphone MAX, Iphone XR and Iphone XS. which iphone is the very NEWEST and which one do you recommend? explain.
    5·2 answers
  • What is the main difference between a search engine and a web browser?
    6·2 answers
  • Complete the function to return the factorial of the parameter using recursion,
    10·2 answers
  • What is the best way of farming exotics in destiny?
    12·2 answers
  • Write a program to assign and display a string value to any variable of your choice
    10·1 answer
  • Lab 8-1: Working with Boot Loader and Runlevels what is the root password
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!