First iteration Job

Source: Internet
Author: User
Tags sca

Package game.volleyball;

Import Java.util.Scanner;

/*

* Use the DD Volleyball scoring system to perform a simple volleyball scoring operation and to check the score of a particular bureau.

* A total of 5 innings, 5 points per board, if one party leads the other 3 points, it is considered a victory for the party.

*/

public class Game {

static Scanner SCA = new Scanner (system.in);

Define an array that holds 5 innings single-round results

Static int[][] Scorearr = new int[5][2];

The result array, which is used to store each round of results for easy query

static string[] result = new STRING[5];

To count the number of victories in two teams.

static int ni1 = 0;

static int ni2 = 0;

public static void Main (string[] args) {

System.out.println ("\ n------Simple Volleyball scoring System--------\n\n\n");

for (int i = 0; i < 5;) {

SYSTEM.OUT.PRINTLN ("Please select your action:");

System.out.println ("1, start scoring 2, query 3, exit system");

User-entered Action selection

int choose = Sca.nextint ();

If the user enters 1

if (choose = = 1) {

Output of the game of the first few innings

System.out.println ("Start Now" + (i + 1) + "innings contest");

Call scoring method

Bounds (i);

i++;

} else if (choose = = 2) {//if user Output 2

System.out.println ("Please enter the number of offices you want to inquire:");

int check = Sca.nextint ();

Determine if the number of user input is started

if (result[check-1] = = null) {

System.out.println ("The game hasn't started yet.") ");

} else {

Find the result from the array

System.out.println (Result[check-1]);

}

} else if (choose = = 3) {//If the user enters 3, outputs the current score, and exits the program

System.out.println ("The game is over, the current score is: Chinese team vs US team ~~~~~" + Ni1 + ":" + Ni2);

SYSTEM.OUT.PRINTLN ("Thank you for using DD scoring system, welcome next use, goodbye");

System.exit (0);

} else {

SYSTEM.OUT.PRINTLN ("Your input is wrong, please re-enter");

}

}

5 innings after the game is over, the game ends, the output results, and exits the program

System.out.println ("The game is over, the current score is: Chinese team vs US team ~~~~~" + Ni1 + ":" + Ni2);

if (Ni1 > Ni2) {

System.out.println ("The Chinese team wins the final victory");

} else {

System.out.println ("The American team wins the final victory");

}

SYSTEM.OUT.PRINTLN ("Thank you for using DD scoring system, welcome next use, goodbye");

}

Scoring methods, statistical results

public static string[] bounds (int num) {

int i = 0;

If both teams score less than or equal to 5

if (Scorearr[num][0] <= 5 && scorearr[num][1] <= 5) {

for (;; i++) {

SYSTEM.OUT.PRINTLN ("Please output the number of the winning party, to add points");

System.out.println ("1, China VS 2, US team");

int team = Sca.nextint ();

if (team = = 1) {

Keep the results of each inning

Scorearr[num][0] + = 1;

System.out.println ("No." + (i + 1) + "Round race end, current score is" + scorearr[num][0] + ":" + scorearr[num][1]);

} else if (team = = 2) {

SCOREARR[NUM][1] + = 1;

System.out.println ("No." + (i + 1) + "Round race end, current score is" + scorearr[num][0] + ":" + scorearr[num][1]);

}

if ((Scorearr[num][0]-scorearr[num][1]) = = 3) {

Result[num] = "+ (num + 1) +" innings, score for "+ scorearr[num][0] +": "+ scorearr[num][1" + "Chinese team victory";

System.out.println (Result[num]);

At the end of each round, add 1 to the final score and return

Ni1 + = 1;

return result;

} else if ((Scorearr[num][1]-scorearr[num][0]) = = 3) {

Result[num] = "First" + (num + 1) + "innings, score for" + scorearr[num][0] + ":" + scorearr[num][1] + "US team victory";

System.out.println (Result[num]);

Ni2 + = 1;

return result;

}

}

} else if (Scorearr[num][0] > scorearr[num][1]) {

Result[num] = "+ (num + 1) +" innings, score for "+ scorearr[num][0] +": "+ scorearr[num][1" + "Chinese team victory";

System.out.println (Result[num]);

Ni1 + = 1;

return result;

} else {

Result[num] = "First" + (num + 1) + "innings, score for" + scorearr[num][0] + ":" + scorearr[num][1] + "US team victory";

System.out.println (Result[num]);

Ni2 + = 1;

return result;

}

}

}

First iteration Job

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.