Posted by **howard** on Friday, October 30, 2009 at 1:07pm.

I have been stuck on this problem in my software design class and I hate going in these places and looking stupid but my professor had a family emergency and my homework is due tomorrow night.

Design a program in pseudocode that calculates the amount of money a person would earn over a period of time if their salary is one penny the first day, and then doubles each day. The program should ask the user for the number of days. Display what the salary was for each day, and then show the total pay for the end of the period. The output should be displayed in dollar amount, not number of pennies.

I cant get it for the life of me

- programming -
**MathMate**, Friday, October 30, 2009 at 2:52pm
This is a geometric progression where the value of the daily salary is multiplied by a constant, namely 2 in this case.

T(n)=2^{n}

The first day is day 0.

Σi=0 to n-1 (2^{i})

=2^{n} - 1

So the first day is 1 cent. (2^{0}=1)

The second day's salary is 2 cents.(2^{1}=2)

The third day's salary is 4 cents.(2^{2}=4)

....

The nth day's salary is 2^{n-1}

and the sum up to the nth day is

2^{n} -1.

Do not forget to divide by 100 to convert cents to dollars.

Be very careful with the variable that you use to store the values.

If you use integer using VB2008 or Java, you will have up to 2^{31}, or 31 days.

If you use long integers, you will have up to 63 days' worth of salary.

In VB2008, you can have up to 80 (I think) bits using type Decimal, so up to 80 days' salary.

However, using Java's BigInteger and BigDecimal class, the number of digits of accuracy is immaterial. I have made programmes that run with 15000 accurate decimal digits.

Generally C-compilers accomodate less precision.

If your teacher does not require accuracy to the last digit, you can always use Double Precision with most of the common languages to get about 15 digits of accuracy, with (almost) no problem of overflow.

## Answer this Question

## Related Questions

- programming - I am in a beginners class in computer programming and we have been...
- programming - I am in a beginners class in computer programming and we have been...
- programming - I am in a beginners class in computer programming and we have been...
- Education/Technology - Productivity software that allows the student to create ...
- C++ - class professor {}; class teacher : public virtual professor {}; class ...
- health - I am going to be making a power presentation on the RED CROSS, I am a ...
- Spanish - Our spanish class has been given a 1-minute speech to write up over ...
- statistics - A professor is interested in determining whether assigning ...
- Excel VBA - Am confused for this class am taking we had to design serval ...
- Mathmatics - A function of two variables is given by, f(x,y) = e^2x-3y Find the...