Ask Java Expert


Home >> Java

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.

Java, Programming

  • Category:- Java
  • Reference No.:- M93085344

Have any Question?


Related Questions in Java

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As