konjammenson
03-22-2005, 11:17 PM
If anyone can help me out on this problem I would sure appreciate it.
The problem: Write a console application to determine which job pays more given the following information: Job A lasts thirty days and pays $25 a day, job B lasts thirty days and pays as follows: $1 first day, $2 second day, $3 third day, and so forth.
ok, so getting job a is real simple. I'm running into problems with finding job b, my code is as follows:
Sub Main()
dim a, b, c, d as integer
a = 0
For c = 1 to 30
a = a + 25
b = 0
for d = 1 To c
b = b + (b+1)
next d
next c
my logic here for b is that:
0 = 0 + (0 + 1) - b now equals 1
then 1 = 1 + (1 + 1) - b now equals 1 + 2 which is 3
for output, i am getting some incredibally high number, when i should be getting 465 (th number i got doing this calculation manually)
If anyone could help me with my logic here I would sure appreciate it.
The problem: Write a console application to determine which job pays more given the following information: Job A lasts thirty days and pays $25 a day, job B lasts thirty days and pays as follows: $1 first day, $2 second day, $3 third day, and so forth.
ok, so getting job a is real simple. I'm running into problems with finding job b, my code is as follows:
Sub Main()
dim a, b, c, d as integer
a = 0
For c = 1 to 30
a = a + 25
b = 0
for d = 1 To c
b = b + (b+1)
next d
next c
my logic here for b is that:
0 = 0 + (0 + 1) - b now equals 1
then 1 = 1 + (1 + 1) - b now equals 1 + 2 which is 3
for output, i am getting some incredibally high number, when i should be getting 465 (th number i got doing this calculation manually)
If anyone could help me with my logic here I would sure appreciate it.