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

  Write a one-class java program

Write a one-class Java program with at least one method (besides main) to determine if the data in your dataset (i.e., in data.txt) follows Benford's law.

  The program randomly generates the quiz question one by

the program randomly generates the quiz question one by one from a set of available questions on general knowledge

  What were the percentages in population growth

What were the percentages in population growth for each consecutive year from 1994 - 2013? 2. What year was the Murder rate the highest

  Calculate the average of two values

Write a program to calculate the average of two values. Initialize the two values to be averaged in main. Pass these two values as parameters on the stack to the average procedure.

  Implement polymorphism and dynamic binding

We are going to implement Polymorphism and dynamic binding by creating generalized methods that accept generalized Employee objects to collect input and display information. However, in the main method we will pass derived objects of the Employee ..

  Implement a hash table structure using the linked list

CMPT 270 - implement a hash table structure using the linked list you developed for assignment and build on top of another object

  Explain the blocking versus nonblocking communications

Explain the Blocking versus nonblocking communications and Name-addressing versus channel-addressing schemes for message passing.

  Develop and test a small procedural java program

ITECH1000 Programming - develop and test a small application that mimics a fortune teller and tells the user what ‘Federation University' star sign their birth year represents and Identify and use the correct syntax of a common programming language

  Write a while loop that prints that number doubled

write a while loop that prints that number doubled without reaching 100. Follow each number with a space. After the loop, print a newline

  The data file being used contains records

The data file being used contains records with an employee's name, the number of hours they worked, and their hourly pay rate. Write a program to read the records of information and output (to the Output window or a dialog box) the employee's name..

  Develop the business tier by using enterprise java beans

Develop the business tier by using Enterprise Java Beans - The business tier will process the data persistence or retrieval requests from users

  Rectangle of the same size and top left corner

Write a Java statement to initialize a variable square with a rectangle object whose top left corner is (10, 20) and whose sides all have length 40. Then write a statement that replaces square with a rectangle of the same size and top left corner ..

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