Write a sub that implements the game

Assignment Help JAVA Programming
Reference no: EM13852108

Write a sub that implements the game "3X+1". It is a very simple game. You start by asking the user to input a positive integer N.

Then, use a loop to test if N is odd or even. If N is odd, then set N= N*3+1. If N is even, then set N= N/2. Repeat this loop until you get N = 1.

You need keep track of how many loops you went through before you get to N = 1.

Report the results (the steps and the corresponding N values, N= 1-20) in a worksheet.

An example of properly working code is as follows:

N=1 N=2 N=3

Steps      0     1

Path of N        1     2     3

1 10 5 16 8 4 2

Reference no: EM13852108

Questions Cloud

Theoretical model of inter temporal budget constraint : The theoretical model of the inter temporal budget constraint for the U.S. economy as a whole suggests that the most common pattern seems to be that: the quantity of?... or the result of?..
Determine optimal mark ups and prices under third-degree : You are the manager of a monopoly that sells a product to two groups of consumers in different parts of the country. Group 1’s elasticity of demand is -2, while group 2’s is -4. Your marginal cost of producing the product is $40. Determine your optim..
Producer surplus is measured as the area : Producer surplus is measured as the area
Differentiated goods : Differentiated goods are NOT a feature of a:
Write a sub that implements the game : Write a sub that implements the game
Critically evaluates current approach to project management : Critically evaluates the current approach to project management methodology in the individual's organisation against the recommended best practice of academic project management principles
True under monopoly : Which of the following is true under monopoly?
Concerning negative externalities : Which of the following is true concerning negative externalities?
Induces firm to use cross-subsidization strategy : The special demand structure that induces a firm to use a cross-subsidization strategy is:

Reviews

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