DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: pennies for pay

  1. #1
    galen smith Guest

    pennies for pay


    I am currently taking c++ and using the Tony Gaddis book for my instruction.
    In this book there is a program that i am having a hard time with. It ask
    a user to input how many days he has worked and he is payed a penny a day
    and doubles every day that he work's. 1st day 1 cent 2nd day 2cents 3rd day
    4 cents etc....
    and then askes for a total amount payed for the number of days worked.It
    also askes for a list of each day and the amount of pay for that day.Any
    help would be greatly appreciated.

  2. #2
    justforfun Guest

    Re: pennies for pay


    if u want output in dollars divide by 100.
    have fun!

    #include<iostream.h>

    void main()
    {
    const int size = 50;
    int days[size] = {0};
    int input;
    int cents = 1;
    int total =0;

    cout<<"\nenter number of days worked: ";
    cin>>input;
    cin.get();

    for(int x = 0; x < input; x++)
    {
    days[x] = cents;
    total += days[x];
    cents *= 2;
    }

    cout<<"\ntotal pay is :"<<total<<" cents";

    for(x = 0; x < input; x++)
    cout<<"\nday "<<x+1<<" = "<<days[x]<<" cents";
    }


    "galen smith" <gsmith@doc.com> wrote:
    >
    >I am currently taking c++ and using the Tony Gaddis book for my instruction.
    >In this book there is a program that i am having a hard time with. It ask
    >a user to input how many days he has worked and he is payed a penny a day
    >and doubles every day that he work's. 1st day 1 cent 2nd day 2cents 3rd

    day
    >4 cents etc....
    >and then askes for a total amount payed for the number of days worked.It
    >also askes for a list of each day and the amount of pay for that day.Any
    >help would be greatly appreciated.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center