posted 4 years ago

The output is :

912

471

THe program is supposed to simulate the way in which numbers are taught to be added in school.

For example

12

+

9

2 + 9 = 11 so results equal 22

I cannot get 1 to add to the middle 7 integer in the output for the life of me.

I fell that the problem lies within its placement in the code or maybe it is being reset at the end of each loop.

Hopefully this question is not to obnoxious.

The output is :

912

471

THe program is supposed to simulate the way in which numbers are taught to be added in school.

For example

12

+

9

2 + 9 = 11 so results equal 22

I cannot get 1 to add to the middle 7 integer in the output for the life of me.

I fell that the problem lies within its placement in the code or maybe it is being reset at the end of each loop.

Hopefully this question is not to obnoxious.

posted 4 years ago

You are adding "262" and "912". When you add last digits 2 and 2, it equals to 4 (which is less than 10). So why do you expect a carry-over of 1(from adding 2 and 2) when you add the second digits 6 and 1? You might try numbers "269" and "912" in that case.

And your code will not compile because of line 34

And your code will not compile because of line 34

**count = ;**
posted 4 years ago

Why are you trying to do arithmetic on Strings? They represent writing, not numbers.

Did you know that you can divide a String into an array of

Did you know that

What is going to happen when you get a 4‑digit number out of two 3‑digit numbers? Will you have enough space in your array?

you should move all that code out of the main method other methods, and you should think of better names for your arrays. There are much better ways to get the carry than using an if.

Did you know that you can divide a String into an array of

`char`s?Did you know that

`char`s are numbers (not letters), and you can do arithmetic with them? So you can use your`char`array to create an`int`array.What is going to happen when you get a 4‑digit number out of two 3‑digit numbers? Will you have enough space in your array?

you should move all that code out of the main method other methods, and you should think of better names for your arrays. There are much better ways to get the carry than using an if.

Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |