dont do my home work but i coudl use some help

Discussion in 'OT Technology' started by flynfrog, Feb 22, 2003.

  1. flynfrog

    flynfrog Cool isnt Cheap

    Joined:
    Jul 16, 2001
    Messages:
    6,620
    Likes Received:
    6
    Location:
    Utah
    this wont complie it says i have an error with iostream.h


    Code:
    //RYAN ELLIS
    //rellis
    //Mike
    //E2
    //internet cost
    //this prgram adds up the total cost of inter net accese
    
    #include <iostream.h>
    #include <math.h>
    //package
    char package;
    //name
    char name[100];
    //number of hours
    int hourstotal;
    int hours;
    //total cost
    float cost;
    
    void main (void)
    {
    //get package and hours used
    cout << "Enter name \n";
    cin >> name; cout<< "\n";
    cout << "Enter package \n";
    cin >> package;
    cout << "How many hours of were used\n";
    cin >> hourstotal;
    
    // dertemin cost
    
    if(package =='A'||package =='a')
      {
       if (hourstotal > 10)
        {
         hours =(hourstotal - 10);
         cost = ((hours * 2) + 9.95);
         }
        else cost = 9.95;
       }
       else if(package =='B'||package =='b')
        {
         if (hourstotal > 20)
         {
          hours =(hourstotal - 20);
          cost = ((hours * 2) + 14.95);
         }
       else cost = 14.95;
        }
    
      //print output
      if (package == 'a' || 'A' || 'b' || 'B')
       {
        cout << name <<" owes " <<cost <<" for package " <<package <<" with " <<hourstotal <<" hours ";
       }
      else (package == 'c' || 'C')
       {
        cout << name <<" owes 29.95 for unlimted access";
       }
    }
     
  2. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    You're missing a semicolon on line 56, but other than that it compiles fine here :dunno:
     
  3. flynfrog

    flynfrog Cool isnt Cheap

    Joined:
    Jul 16, 2001
    Messages:
    6,620
    Likes Received:
    6
    Location:
    Utah
    im getting IOSTREAM>H(25,2):error directive must use c++ for the type iostream.
     
  4. Scoob_13

    Scoob_13 Anything is possible, but the odds are astronomica

    Joined:
    Oct 5, 2001
    Messages:
    73,784
    Likes Received:
    38
    Location:
    Fort Worth. Hooray cowgirls.
    Code:
      else [b]if[/b] (package == 'c' || 'C')
       {
        cout << name <<" owes 29.95 for unlimted access";
       }

    and really it should be:

    Code:
      else [b]if[/b] (package == ('c' || 'C'))
       {
        cout << name <<" owes 29.95 for unlimted access";
       }

    And to correct your issue, you need to include the command cin.ignore(1); before your request for packages, like this:

    Code:
    cout << "How many hours of were used\n";
    [b]cin.ignore(1);[/b]
    cin >> hourstotal;
     
    Last edited: Feb 22, 2003
  5. Scoob_13

    Scoob_13 Anything is possible, but the odds are astronomica

    Joined:
    Oct 5, 2001
    Messages:
    73,784
    Likes Received:
    38
    Location:
    Fort Worth. Hooray cowgirls.
    And, just to be picky, you need to create a better menu system using the Switch/Case method :p
     
  6. flynfrog

    flynfrog Cool isnt Cheap

    Joined:
    Jul 16, 2001
    Messages:
    6,620
    Likes Received:
    6
    Location:
    Utah
    im still gettiging the same error ive tried two differnt compilers

    it wont run in the unix compiler either
     
  7. flynfrog

    flynfrog Cool isnt Cheap

    Joined:
    Jul 16, 2001
    Messages:
    6,620
    Likes Received:
    6
    Location:
    Utah
    and i appreicate teh comments im a teriible programer i admit it
     
  8. Scoob_13

    Scoob_13 Anything is possible, but the odds are astronomica

    Joined:
    Oct 5, 2001
    Messages:
    73,784
    Likes Received:
    38
    Location:
    Fort Worth. Hooray cowgirls.
    No such thing as a terrible programmer, just a terrible program :o

    And try Visual C++ 6.0, it compiles fine
     
  9. flynfrog

    flynfrog Cool isnt Cheap

    Joined:
    Jul 16, 2001
    Messages:
    6,620
    Likes Received:
    6
    Location:
    Utah
    well to hand it in it has to compile on the unix compiler
     
  10. Scoob_13

    Scoob_13 Anything is possible, but the odds are astronomica

    Joined:
    Oct 5, 2001
    Messages:
    73,784
    Likes Received:
    38
    Location:
    Fort Worth. Hooray cowgirls.
    Oh, shit, dunno about a unix compiler :o


    I don't see why it would be different though
     
  11. flynfrog

    flynfrog Cool isnt Cheap

    Joined:
    Jul 16, 2001
    Messages:
    6,620
    Likes Received:
    6
    Location:
    Utah
    ok i ahve it compiling on the unix server

    but it doesnt work right

    the output is messed up i get both out puts options
     
  12. flynfrog

    flynfrog Cool isnt Cheap

    Joined:
    Jul 16, 2001
    Messages:
    6,620
    Likes Received:
    6
    Location:
    Utah
    it was in my or statments
     
  13. flynfrog

    flynfrog Cool isnt Cheap

    Joined:
    Jul 16, 2001
    Messages:
    6,620
    Likes Received:
    6
    Location:
    Utah
    yay i got it done go me
     
  14. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    It worked fine on my Unix compiler to start with (g++ v2.96)...
     

Share This Page