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

  Write a program that uses a dynamic list of strings

Write a program that uses a dynamic list of strings to keep track of a list of chores that you have to accomplish today.

  Implement all the methods in each of the classes

You need to have an array for this database, the size of this database is given by MAX. You may simply set MAX to be 8 to save your effort in filling information.

  What is abstract class and how it differ from regular class

What is an abstract class and how does it differ from a regular class? Why are abstract class constructors defined as protected

  Create a driver class with a main method

Create a driver class with a main method that creates a course, adds several students, prints a roll, and prints the overall course test average

  Determine total annual compensation of a salesperson

Write a Java application using NetBeans Integrated Development Environment (IDE) that calculates the total annual compensation of a salesperson. Consider the following factors: A salesperson will earn a fixed salary of $45,000

  Define multi-threaded programming in java using locks

Define Multi-threaded Programming in Java Using Locks, To practice programming cooperating, synchronized multiple threads of execution

  What are the constraints on the argument values

What makes a program easy to modify and describe the order of magnitude of the following code section using Big(O) notation.

  How do you create a class in java to enable its object

How do you create a class in Java to enable its object to be persistent and what are Java data streams and how are they used to facilitate storage and retrieval of persistent objects?

  Program designs used in developing java applications

program designs used in developing Java applications

  Write a java program that uses a search tree of strings

Write a Java program that uses a search tree of strings to sort text lines in alphabetic order. You may choose how you de?ne alphabetic order as long as there is some sense in the de?nition. You may also choose what kind of tree you use.

  Reads contents of two vectors

Write a program that reads contents of two vectors, and then displays the sum of these two vectors. The program should prompt the user to enter the size of the vectors first.

  Outline a test plan for a substantial real-life system

Describe how you would approach the design and testing process to ensure success and quality in the result and where are the risks? How are you going to address them?

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