Programming Homework Help

Programming Homework Help. do 2 simple java programs

Program 1 Algorithm

Problem statement:

Write a Java program to add up the digits of a number entered by the user and output the result. You may not use an array top perform this task. The program should be able to handle an integer of any size.

For example, if the number 1256 was entered, the sum would be:

SumOfDigits = 1 + 2 + 5 + 6 = 14

Solution:

The following Algorithm could be used:

Define variables

Get input number

Get each digit of input number

Add digit to sumOfDigits

Output sumOfDigits

loop

remainder = inputNumber % 10

sumOfDigits = sumOfDigits + remainder

inputNumber = inputNumber – remainder

inputNumber = inputNumber / 10

end loop

Some helpful code snippets:

To get length of input number

int lenOfNum = String.valueOf(inputNum).length();

To get number from keyboard

int inNumber = Integer.parseInt(s.nextLine()); // What about validating input?

program 2

Using the files from the in-class assignment add two additional animals of your choice. For each animal add two additional methods appropriate to your particular animal.

As the majority of the code for this program exists you will not need an algorithm.

send me two program please

Programming Homework Help

 
"Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!"