Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

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

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

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 ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

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 ...

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 ...

  • 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