Josh Brand

Greenhorn

Posts: 14

posted 3 months ago

Good morning/afternoon/evening. I am attempting to write a program Value that will multiply/add/subtract two numbers from the specified char type.

The desired output is;

Starting Application...

Creating Counter object with a starting value of 1 and a step size of 3

*** Counting up 5, operation is *

counter = 1

counter = 3

counter = 9

counter = 27

counter = 81

Creating Counter object with a starting value of 5

*** Counting up 2, operation is -

counter = 5

counter = 4

*** Counting up 2, operation is ?

counter = 3

Invalid operation: ?

I am getting;

Starting Application...

*** Counting up 5

fail

Creating Counter object with a starting value of 1

*** Counting up 2

counter = 5

fail

Creating Counter object with a starting value of 1

*** Counting up 2

counter = 4

counter = 4

counter = 4

Creating Counter object with a starting value of 1

Could anyone please point me in the right direction?

Thankyou very much!

Good morning/afternoon/evening. I am attempting to write a program Value that will multiply/add/subtract two numbers from the specified char type.

The desired output is;

Starting Application...

Creating Counter object with a starting value of 1 and a step size of 3

*** Counting up 5, operation is *

counter = 1

counter = 3

counter = 9

counter = 27

counter = 81

Creating Counter object with a starting value of 5

*** Counting up 2, operation is -

counter = 5

counter = 4

*** Counting up 2, operation is ?

counter = 3

Invalid operation: ?

I am getting;

Starting Application...

*** Counting up 5

fail

Creating Counter object with a starting value of 1

*** Counting up 2

counter = 5

fail

Creating Counter object with a starting value of 1

*** Counting up 2

counter = 4

counter = 4

counter = 4

Creating Counter object with a starting value of 1

Could anyone please point me in the right direction?

Thankyou very much!

Dave Tolls

Ranch Foreman

Posts: 3068

37

posted 3 months ago

That implies (to me, with no other information) that should be in the constructor, so the constructor should take two values, a starting value and a step value.

This then implies that the

A couple of comments on the code itself. Get your indentation right, as it's hard to follow the flow of poorly formatted code.

Also give your variables meaningful names. Again, this helps people (including yourself) when reading the code.

- 1

*Creating Counter object with a starting value of 1 and a step size of 3*

That implies (to me, with no other information) that should be in the constructor, so the constructor should take two values, a starting value and a step value.

**** Counting up 5, operation is **

This then implies that the

`countUp`method should take two values, a number of steps and an operation.

A couple of comments on the code itself. Get your indentation right, as it's hard to follow the flow of poorly formatted code.

Also give your variables meaningful names. Again, this helps people (including yourself) when reading the code.

Josh Brand

Greenhorn

Posts: 14

posted 3 months ago

Thank you David, this issue is now resolved. Thank you very much!

Dave Tolls wrote:Creating Counter object with a starting value of 1 and a step size of 3

That implies (to me, with no other information) that should be in the constructor, so the constructor should take two values, a starting value and a step value.

*** Counting up 5, operation is *

This then implies that thecountUpmethod should take two values, a number of steps and an operation.

A couple of comments on the code itself. Get your indentation right, as it's hard to follow the flow of poorly formatted code.

Also give your variables meaningful names. Again, this helps people (including yourself) when reading the code.

Thank you David, this issue is now resolved. Thank you very much!

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