Write an algorithm and convert it to a java program

Assignment Help JAVA Programming
Reference no: EM131983305

Fundamentals of Operating Systems and Programming Assignment -

Write an Algorithm/flowchart and then convert it to a java program for given game of NIM.

Purpose of the assessment (with ULO Mapping) - This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements in them.

  • Apply principles of abstraction and problem solving in an object-oriented programming language.
  • Apply knowledge of programming constructs in developing computer programs.
  • Create programs based on incremental development processes of designing, coding, testing and debugging.

Assignment Specification -

Write a detailed algorithm and a program that plays the ancient Chinese game of NIM. Actually, this is a simplified version of the game. In this game, the person who runs your program will be one of the two human players, your program will be a simple Artificial Intelligence (AI) that will serve as the other player, as well as provide the narrative for the game and keep score, invite a friend to be the third player. Your program must keep score impartially while participating in the game, but this is not a difficult task for the computer.

Rules of the Game:

Number of participating Players: 2 students and 1 computer

The player who goes first shall define the number of stones in the pile. The number must be between 30 to 50.

Each player then removes some number (between 1 to 3) of stones from the pile in turn until one player removes the final stone.

The player who goes first:

I. Provides the number of stones to be placed in the pile,

ii. Removes the first set of 1 to 3 stones

Other player removes a set of 1 to 3 stones.

The players then take turns(iteration) until the final stone is removed.

The player who removes the final stone is the winner (student player 1, student player 2 and the computer).

The program must perform the following:

Use the System I/O (print (), or println()) to introduce and describe the game, Computer shall introduce itself as the AI player, and prompt the human players for his or her names along with MIT Ids.

The program must use a Scanner object to receive the inputted response.

The response must be assigned to a properly typed variable.

Uses printf() to display a greeting to the human player that incorporates the name provided in response to the prompt: Welcome <user's name> to the game of Taking Stones.

The user's name must be output in proper name case (i.e., mixed case starting with upper case for the first letter) regardless of the case the user types in.

The users shall input the number of stones to be picked either by using a standard random number generator function or may input according to their own strategy but the number should be less than or equal to three (3).

Java has two ways to generate random numbers

  • Math. Random method from the Java API Math
  • java.util.random Class and the appropriate method from that class, to generate this number for the human player

The program must reject and display a valid message if the number of stones to be removed are either less than one(1) or more than three(3) students and remind them the game constrains.

Prompt that player to re-enter an appropriate number.

Your program should have the computer use the optimal playing strategy. The optimal strategy is as follows: Divide the remaining number of stones by three. If the remainder is zero, then two stones are removed, or else one stone is removed. For example, if the remaining number of stones is nine or fifteen, then two stones are removed; if the remaining number of stones is eight or ten, then one stone is removed.

Both the human players shall have their own strategies to play.

When one of the player has won a game, the program must output a congratulatory message naming the winner along with ID.

Your program should allow the users to play additional games of NIM as long as he/she enters a "y" or "yes" (lowercase or uppercase) in response to a "Do you want to play again?" prompt.

Attachment:- Assignment File.rar

Verified Expert

In this assignment we have develop nim chines game.We have use java programming for develop NIM game.In this game, there are three player 1st is computer and another 2 are human .Every one pick the stone from given stone .At last who pick the last stone will be winner.

Reference no: EM131983305

Questions Cloud

About confidentiality agreements : All of these are correct about confidentiality agreements except one of them. which one?
What are the negatives of debt financing : Why do firms typically borrow less than half of their capital, i.e., what are the negatives of debt financing?
Why do the bonds coupon rates vary so widely : Why do the bonds coupon rates vary so widely? What wuld be the value of each bond if they had annual coupon payments?
What is the value of project : At the end of the 5th year, High Flyer will sell the distribution center for an estimated amount of $10,000. High Flyer's WACC is 19% and it faces a 30% tax
Write an algorithm and convert it to a java program : MN404- T1 2018 Fundamentals of Operating Systems and Programming Assignment - Write an Algorithm/flowchart and then convert it to a java program
How much will you have for down payment at end of year three : You want to buy a house within 3 years, and you are currently saving for the down payment. How much will you have for a down payment at the end of Year 3?
Business valuation professional : 1. The most important element(s) in selecting a business valuation professional include which of the following:
How much of everyday life is organized by gender : When you stop to think about it, much of what most people do during the routine of a normal day is categorized as either masculine or feminine.
What are the breakeven points for position : What are the breakeven points for this position? What must this investor believe about the stock price in order to justify this position?

Reviews

len1983305

5/15/2018 6:09:55 AM

Submission Guidelines - All work must be submitted on Moodle by the due date along with the completed Assignment Cover Page. The assignment must be in MS Word format, 1.5 spacing, 11-pt Calibri (Body) font and 2 cm margins on all four sides of your page with appropriate section headings. Reference sources must be cited in the text of the report and listed appropriately at the end in a reference list using IEEE referencing style. Algorithm/flow chart to be submitted in a word doc1. Draft copy and final version of the program to be submitted in a word doc2 and doc3 respectively. Both file names must have student Id as part of the file names. Students must ensure before submission of final version of the assignment that the similarity percentage as computed by Turnitin has to be less than 10%.

len1983305

5/15/2018 6:09:49 AM

For assignments, students are encouraged to consult each other, the lecturer, tutor or anyone else for that matter. However, the assistance offered or accepted should not go beyond a discussion of the problem and a sketch of a solution. But in your assignment, do not use any written material from the discussion/website/book. If you can reconstruct the discussion and complete the solution on your own, then you have learned the material (and that is the objective of this course!).

len1983305

5/15/2018 6:09:44 AM

All the minute details have to be addressed in the algorithm. Error free, well commented java program reflecting each line of the algorithm. Following points to be considered: Include appropriate import statements, Include a comment at the beginning of your program with basic information and a description of the program. Your code should be properly indented. Give meaningful names to variables and classes in your code. Correct use of programming structures. Your program compiles successfully without any errors. Your program is interactive and gives correct output. Your program should follow all the rules mentioned above. Sufficient test cases considering all the requirements must be provided with valid and invalid inputs. Students who fail to submit draft copies of both the algorithm and the program shall lose marks.

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd