Changing double time to double cost

This is a discussion on Changing double time to double cost within the C++ Programming forums, part of the General Programming Boards category; Hi again, I looked on the boards, and could not find a solution to the exericse on my book, I ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    62

    Changing double time to double cost

    Hi again,

    I looked on the boards, and could not find a solution to the exericse on my book, I can't think of a way to make a programme, add a certain cost to each hour.
    For example, if I had 3 hours of work done and I am charing in 0.50 a hour, how do I make the complier know it's per hour?
    I mean I will post my code but it dont make much sense cause I dont know what to do in the first place.
    Code:
    double calculateCharges()
    {
    double charge = 0;
    double total = 0;
    
    		
    		  charge = hours;
    		  total += charge;
    		
    			return total;
    }
    As you can see that wont do anything, but a push in the right direction would be aperciated.
    Thank you.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Code:
    charge = hours * .5;
    total += charge;
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    62
    Thanks, I aperciate it

    now for my own benifit I beter remember that.

    Thanks again

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ to C Conversion
    By dicon in forum C Programming
    Replies: 7
    Last Post: 06-11-2007, 09:38 PM
  2. Sending an email in C program
    By Moony in forum C Programming
    Replies: 28
    Last Post: 10-19-2006, 11:42 AM
  3. Help with multi function progam
    By WackoWolf in forum C Programming
    Replies: 22
    Last Post: 10-13-2005, 03:56 AM
  4. Certain functions
    By Lurker in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2003, 01:26 AM
  5. I apologize. Good bye.
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 05-03-2002, 07:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21