Write a program that prompts the user for an integer

Assignment Help JAVA Programming
Reference no: EM132097874

Assignment Overview

The aim of this project is practice the use of while loops and conditionals statements.

You are going to write a program that prompts the user for an integer and then determines the additive persistence and corresponding additive root, and the multiplicative persistence, the corresponding multiplicative digital root of that integer.

You will continue to do so until the user quits

Background

There are many properties of numbers that one can investigate. The ancient Greeks were fascinated with the properties of integers, even ascribing them mystical properties.

One such property is an integer's additive persistence and its resulting additive root.

Additive persistence is a property of the sum of the digits of an integer. The sum of the digits is found, and then the summation of digits is performed on the sum, repeating until a single integer digit is reached.

The number of such cycles is that integer's additive persistence. Consider the following example:

The beginning integer is 1234

Sum its digits is 1+2+3+4 = 10

The integer is now 10

The sum of its digits is 1 + 0 = 1

The integer is 1. When the value reaches a single digit, we are finished. This final integer is the additive root

The number of cycles is the additive persistence. The integer 1234 has an additive persistence of 2 (first sum was 10, then the second sum was 1). The final digit reached is called the integer's additive digital root. The additive digital root of 1234 is 1.

The multiplicative persistence and resulting multiplicative root are determined the same way, only multiplying the digits of an integer instead of adding. For example

The beginning integer is 1234

The product of 1*2*3*4 = 24

The integer is now 24

The product of 2*4 = 8

The integer is now 8. When the value reaches a single digit, we are finished. This final integer is the multiplicative root.

As before, the number of cycles is the multiplicative persistence. For 1234, the multiplicative persistence is 2, and its multiplicative root is 8.

Program Specifications

The program should run as follows.

1) Ask the user for an integer.

2) If the given integer is a single digit, report it's additive persistence and multiplicative persistence as 0 and both its additive and multiplicative \ root as itself.

3) If the integer is less than 0, that is a signal to quit the program.

4) Otherwise, find the additive/multiplicative persistence and additive/multiplicative root of the given integer and report the results to the user

5) Continue by prompting the user until they quit.

Deliverables

proj02--- your source code solution (remember to include your section, the date, project number and comments).

Please be sure to use the specified file name, i.e. "proj02"

Electronically submit a copy of the file.

Hard Copies of Source Code and Output.

Getting Started

1) Create the proj02 as usual.

2) Break the problem down into parts. Some obvious parts:

a.gather input from the user, and check for negative numbers (the quit condition)

b.write a loop around the queries that can do the queries until the stop condition is reached

c.write a loop that can sum the digits of an integer until it reaches a single digit.

d.write a loop that can take the produce of the digits of an integer until it reaches a single digit, using the above approach

e.Get the whole thing to work with one or the other (additive, multiplicative) before you address the other

3) How do you get the digits of an integer? Look at a combination of division (/) and remainder(%) operators on integers. Try it out in idle first

4) I would add some "diagnostic output" so you can be sure things are working as they should. For each pass through the loop of the additive (or multiplicative) persistence, print each new integer created.

Reference no: EM132097874

Questions Cloud

Write a program to determine which customers must be served : Write a program to determine which customers must be served from each field stations.
What is the value of ending inventory under variable costing : Peachtree Company manufactures peach jam. Because of bad weather, its peach crop was small. What is the value of ending inventory under variable costing
How is the data used to build a recommendation system : What are recommender systems, how are they developed, and how is the data used to build a recommendation system obtained?
Report on internal control over financial reporting : Write a 1,050- to 1,400-word paper on the following: The Independent Registered Public Accounting Firm's Report on Internal Control Over Financial Reporting
Write a program that prompts the user for an integer : Write a program that prompts the user for an integer and then determines the additive persistence and corresponding additive root.
Discuss the hr impacts of these trends : HRMT11011 Human Resource Management - discuss the HR impacts of these trends in relation to the key stakeholders such as employers and employees
Compute donaldson total wages and fringe benefits : Assume that Bringer of Rain Inc. treats all fringe benefits as part of manufacturing overhead. Compute Donaldson's total wages and fringe benefits
Write a pic18 assembly program to compute the sum : Write a PIC18 assembly program to compute the sum of 1 + 2 + 3 +4 +5.
Convert a temperature from celsius to fahrenheit : Convert a temperature from Celsius to Fahrenheit using the formula F = (9/5 C) + 32.

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