Thread: Time

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    14

    Time

    I have an assignment on a phone bill and I am havig a hardtime understacnding the time aspect of my program. does any one know where I can get help in the tutorials.
    Jessica

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I am havig a hardtime understacnding the time aspect of my program
    Well, what would the time aspect of your program be? We're not exactly mind readers.

    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    14
    I have to do a phonebill with the information in a data file. and I have to use military time and I am always getting errors where the : is.

  4. #4
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    Posts
    408
    Post your code...

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    14
    I am not completely finished yet but here it is
    [code]

    #include <iostream>
    #include <fstream>
    #include <cctype>

    void getinfo(int&length, double& time, double& cost, char& day, char& day2)\
    ;
    void showbill(int length, double time, double cost, char day, char day2);
    int main()
    {
    using namespace std;
    char ans;
    do
    {
    int length;
    double time, cost;
    char day, day2;
    getinfo(length, time, cost, day, day2);
    showbill(length, time, cost, day, day2);
    cout << "Do you want to recalculate your phone bill again (y/n):";
    cin >> ans;
    cout << endl;
    }while (ans == 'Y' || ans == 'y');
    cout << "Thank you good bye.\n\n";
    return 0;
    }
    void getinfo(int& length, double& time, double& cost, char& day, char& day2)

    {
    using namespace std;
    ifstream in;
    in.open("/home1/c/a/acsi201/samples/phonedata");
    double costd, coste, costw, weekendrate = 0.15, eveningrate = 0.25, dayr\
    ate = 0.45;
    char M,O,T,U,W,E,H,F,R,S,A;
    cost == length * dayrate;
    cost == length * eveningrate;
    cost == length * weekendrate;
    toupper (('m' && 'o') ||
    ('t' && 'u') ||
    ('w' && 'e') ||
    ('t' && 'h') ||
    ('f' && 'r'));
    if ((day == M && day2 == O) ||
    (day == T && day2 == U) ||
    (day == W && day2 == E) ||
    (day == T && day2 == H) ||
    (day == F && day2 == R))
    if (time >= 1 && time < 13 )
    cout << coste;
    else if ((time <= 18) || (time >= 8))
    cout << costd;
    }
    void showbill(int length, double time, double cost, char day, char day2)
    {
    using namespace std;

    cout << " Day Time Cost \n";
    cout << day << time << cost;
    }
    Jessica

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    14
    I guess my main question would be is do i use a decimal point (14.59) instead of a colon (14:59) to represent military time 2:59 pm
    Jessica

  7. #7
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    I'm confused as to why you can't simply do this.

    cout << var1 << ":" << var2 << endl;

    Obviously var1 & var2 are not from your program but you get the idea.

  8. #8
    Registered User
    Join Date
    Apr 2002
    Posts
    14
    I can use this even if the variable are coming from a data file
    Jessica

  9. #9
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Um, I'd have to see the program. What you posted above is not enough for me to really see what is happening. Maybe you could comment out that part where you would like the cout to be and attach the zip to your post. I will try to look at it then, or post the entire source in the [C_ODE] // blah [/C_ODE] tags, without the underscore.

  10. #10
    Registered User
    Join Date
    Jan 2002
    Posts
    559
    Well, one thing to look at is where you're declaring using namespace std; It only needs to be declared once, and that's underneath your includes but before any function blocks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to get current time
    By tsubasa in forum C Programming
    Replies: 3
    Last Post: 05-01-2009, 02:03 AM
  2. Replies: 11
    Last Post: 03-29-2009, 12:27 PM
  3. Help with assignment!
    By RVDFan85 in forum C++ Programming
    Replies: 12
    Last Post: 12-03-2006, 12:46 AM
  4. calculating user time and time elapsed
    By Neildadon in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2003, 06:00 PM
  5. time class
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-11-2001, 10:12 PM