programming

posted by .

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 -

    This is a geometric progression where the value of the daily salary is multiplied by a constant, namely 2 in this case.

    T(n)=2n
    The first day is day 0.
    Σi=0 to n-1 (2i)
    =2n - 1

    So the first day is 1 cent. (20=1)

    The second day's salary is 2 cents.(21=2)

    The third day's salary is 4 cents.(22=4)

    ....
    The nth day's salary is 2n-1

    and the sum up to the nth day is
    2n -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 231, 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.

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. design

    In an effort to promote a better understanding of what design is and how to discuss it, your firm is having a weekly series of meetings. Within your first week, please find a design to include in your presentation that is different …
  2. programming

    I am in a beginners class in computer programming and we have been designing our programs in pseudocode format and this is a homework question I have to solve this is how the question is written on my paper...can you please help, Thanks. …
  3. programming

    I am in a beginners class in computer programming and we have been designing our programs in pseudocode format and this is a homework question I have to solve this is how the question is written on my paper...can you please help, Thanks. …
  4. programming

    I am in a beginners class in computer programming and we have been designing our programs in pseudocode format and this is a homework question I have to solve this is how the question is written on my paper...can you please help, Thanks. …
  5. Computer Programing & Logic Design

    Submit pseudocode and a flowchart for the following programming exercise: Software Sales A software company sells a package that retails for $99. Quantity discounts are given according to the following table: Quantity Discount 10-19 …
  6. Excel VBA

    Am confused for this class am taking we had to design serval procedures that do different things: 6 procedures were sine, cosine, cube, square, common log, and natural log. In order to get this values we had to design loops. I have …
  7. Education/Technology

    Productivity software that allows the student to create professional-looking pages with text, graphics, digital pictures, stylized headlines, and professionally prepared design elements is called: A) Desktop publishing software. B) …
  8. Programming logic design

    Design a class named DVD that has fields for the DVD category , tittle and price include methods to set and get the value for each field write pseudocode that definnes this class.
  9. Geometry

    Javier made a square design in art class. The area of the design is 196 square inches. Wat is the length, in inche's, of one side of the design?
  10. Software Engineering

    When did you start "speech and Auditory interfaces" who made it?

More Similar Questions