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

  Presell a limited number of cinema tickets

Write an application to presell a limited number of cinema tickets. each buyer can buy as many as 4 tickets. No more than 100 tickets can be sold. Implement a program called TicketSeller that prompts the user for the desired number of tickets and the..

  Process of identifying classes or functions for replacement

A 700- to 1050-word paper describing the following: How the two programs were selected and The process of identifying the classes or functions for replacement

  Develop a graphical user interface based java program

Develop a Java program that can communicate with a real SMTP email server for sending emails. TNE 60003 - introduction to network programming, You program should provide a GUI and can successfully send the SMTP commands to the mail server

  Automated code coverage and cyclomatic complexity analyses

Automated code coverage and cyclomatic complexity analyses -

  Implement the nested loops

The user has also already entered a mystery number they want the following series to calculate based upon their current numbers (also relatively logical in size).

  Create a gui client side application that is a java version

q1. create a gui client side application that is a java version of notepad giving the ability to open modify and save

  Develop a program that will handle a golfer and his scores

develop a program that will handle a Golfer and his scores. The program will be comprised of two classes: a Golfer class that will manage all the golfer's scores and a Score class.This is a class designed to represent a golfer including his name, hom..

  Prepare factorial program in java

You need to prepare a Factorial Program in Java with stateless EJB concept- There must be three java files 1.Factorial.java 2.FactorialBean.java 3.FactorialHome.java Theses Three file must be in package named 'mypack'.

  Implement a shopping cart class with user interface

project will be to implement a shopping cart class with user interface (UI) that contains main() in Net Beans. The UI class will be used to perform user input/output and to invoke the appropriate methods of shopping cart class. When your program star..

  Develop and test stand alone java applications

Gain practical skills in Graphical User Interface (GUI) programming by implementing an event driven application.

  Prompt the user for a series of numbers

Prompt the user for a series of numbers that may be either a binary number or a decimal number.

  Write a class that implements an ordered list of strings

In this problem you will write a class that implements an ordered list of Strings.

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