Thread: making a window program

  1. #16
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    ok, i see you are trying to do something not all that complicated..

    I suggest you read the tutorials.. theyll help you alot.

    first off to get a number input you you use
    Code:
    cin >> variable
    it will pause the program untill the user inputs a number.

    then variable is the number the user inputed.

    and you are still trying to add a string to a number:
    Code:
    if( i > k ){
       cout<<"Gewinn oder Verlust:                                                                    +" + ( i - k );
    }
    that is imposible, are you trying to get the user to input a number and then add the (i -k) to it?
    because what you have there right now makes no sence...
    also your main() function does not return any value. main() must return something (read thee tutorial on functions).

    Code:
    #include <iostream>
    #include <stdlib.h>
    using namespace std;
    
    int main()
    {
      double a;
      double b;
      double c;
      double d;
      int e;
      int f;
      int g;
      int h;
      int i;
      int j;
      double k;
      double l;
      double m;
      int n;
      int o;
      int p;
      int r;
    
       cout<<"Geben Sie bitte der Anzahl der übrig gebliebene Brezeln ein: ";
       cin >> e;
       n = 7 - e;
       
    
       cout<<"Geben Sie bitte der Anzahl der übrig gebliebene Laugenbrötchen ein: /n";
       cin >> f;
       o = 5 - f;
       
    
       cout<<"Geben Sie bitte der Anzahl der übrig gebliebene Käsestangen ein: /n";
       cin >> g;
       p = 5 - g;
       
    
       cout<<"Geben Sie bitte der Anzahl der übrig gebliebene Laugencroissants ein: /n";
       cin >> h;
       r = 5 - h;
       
       j = n + o + p + r;
    
       cout<<"Geben Sie bitte Kassenstand am Ende in € ein: /n";
    
    
       a = n * 0.5;
       b = o * 0.4;
       c = p * 0.7;
       d = r * 0.65;
       k = 10 + a + b + c + d;
       l = e * 0.50 + f * 0.40 + g * 0.70 + h * 0.65;
       m = 7 * 0.50 + 5 * 0.40 + 5 * 0.70 + 5 * 0.65 + 10;
    
       cout<<"Kassenstand wenn alles verkauft worden sein würde:         ";
       cout<<"So viel Geld müssen Sie in die Kasse haben:                        ";
       cout<<"Preis der übrig gebliebene Waren:                                            ";
       cout<<"Aktuelle Kassenstand am Ende:                                                ";
       if( i < k ){
       cout<<"Gewinn oder Verlust:                                                                   -";
    }
       if( i > k ){
       cout<<"Gewinn oder Verlust:                                                                    +";
    }
       if( i == k ){
       cout<<"Gewinn oder Verlust:                                                                     ";
    }
       system("PAUSE");
       return 0;
       
    }
    it works fine, but the variable 'i' has no value. so you youll get an error.

  2. #17
    Registered User DDX's Avatar
    Join Date
    Mar 2005
    Posts
    29
    works fine but everything is a chaos....i mean it looks like helll......how do i make that every cout is displayed over each other and to dislay a + in front of number and if more than 0 and a - in front if less than zero

  3. #18
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    Oh.
    ok, just insert '<<' infront of the number and remove the '+' sing.

    there is alot of empy spaces on the last few strings you might want to remove them.

    NOTE: 'i' has no value!
    Code:
    #include <iostream>
    #include <stdlib.h>
    using namespace std;
    
    int main()
    {
      double a;
      double b;
      double c;
      double d;
      int e;
      int f;
      int g;
      int h;
      int i;
      int j;
      double k;
      double l;
      double m;
      int n;
      int o;
      int p;
      int r;
    
       cout<<"Geben Sie bitte der Anzahl der übrig gebliebene Brezeln ein: ";
       cin >> e;
       n = 7 - e;
       
    
       cout<<"Geben Sie bitte der Anzahl der übrig gebliebene Laugenbrötchen ein: ";
       cin >> f;
       o = 5 - f;
       
    
       cout<<"Geben Sie bitte der Anzahl der übrig gebliebene Käsestangen ein: ";
       cin >> g;
       p = 5 - g;
       
    
       cout<<"Geben Sie bitte der Anzahl der übrig gebliebene Laugencroissants ein: ";
       cin >> h;
       r = 5 - h;
       
       j = n + o + p + r;
    
       cout<<"Geben Sie bitte Kassenstand am Ende in € ein: \n";
    
    
       a = n * 0.5;
       b = o * 0.4;
       c = p * 0.7;
       d = r * 0.65;
       k = 10 + a + b + c + d;
       l = e * 0.50 + f * 0.40 + g * 0.70 + h * 0.65;
       m = 7 * 0.50 + 5 * 0.40 + 5 * 0.70 + 5 * 0.65 + 10;
    
       cout<<"Kassenstand wenn alles verkauft worden sein würde: " << m << endl;
       cout<<"So viel Geld müssen Sie in die Kasse haben: " << k << endl;
       cout<<"Preis der übrig gebliebene Waren: " << l << endl;
       cout<<"Aktuelle Kassenstand am Ende: " << i << endl;
       if( i < k ){
       cout<<"Gewinn oder Verlust: -" << (i - k) << endl;
    }
       if( i > k ){
       cout<<"Gewinn oder Verlust: +" << (i - k) << endl;
    }
       if( i == k ){
       cout<<"Gewinn oder Verlust: " << (i - k) << endl;
    }
       system("PAUSE");
       return 0;
       
    }

    EDIT:

    you might want to insert '<< endl;' at the end
    Last edited by mrafcho001; 03-20-2005 at 01:12 PM.

  4. #19
    Registered User DDX's Avatar
    Join Date
    Mar 2005
    Posts
    29
    Code:
     cout<<"Kassenstand wenn alles verkauft worden sein wurde: " << m;
    
       cout<<"So viel Geld mussen Sie in die Kasse haben: " << k;
    
       cout<<"Preis der ubrig gebliebene Waren: " << l;
    
       cout<<"Aktuelle Kassenstand am Ende: " << i;
    
       if( i < k ){
       cout<<"Gewinn oder Verlust: -" << (i - k);
    }
       if( i > k ){
       cout<<"Gewinn oder Verlust: +" << (i - k);
    }
       if( i == k ){
       cout<<"Gewinn oder Verlust: " << (i - k);
    }
       system("PAUSE");
       return 0;
       
    }
    thats the onlt problem left....i know im a nooying pest but its a dream come true....well almost........
    ive done what u said everything is perfect till now except the following code.
    the following is display each other after[U] each other, but it gotta be each other over[I] each other.

  5. #20
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    as i said above add " << endl" before the ";"

    and it will put whatever is next on a new line

  6. #21
    Registered User DDX's Avatar
    Join Date
    Mar 2005
    Posts
    29
    I Love you !!!!!!!!!
    thank you thank you thank you thank you thank you

    P.S. Do you know how to make windowed programs?

  7. #22
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    No, i am trying to find a book or good tutorials on how to do that. but i am ok with most of the other C++ things

    If you need more help:

    AIM: StupidTerorrists

  8. #23
    Registered User DDX's Avatar
    Join Date
    Mar 2005
    Posts
    29
    k well the tuts so far are for console apps........it would be a great idea and help if experienced users would write a tutorial on how to make windowed programs

  9. #24
    Registered User DDX's Avatar
    Join Date
    Mar 2005
    Posts
    29
    Also, the tutorials so far are quite...... well......lets say the long and harder way made.,
    i was thinking on the command and what between it can be and what would that result if that or if that or if that etc......quite good idea aint it?

  10. #25
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    There are many. If you feel that you're advanced enough in C++ to handle Win32 API, then go do a search for "theForger" on google. Otherwise, go buy a C++ book and learn some more basics before asking again how to make windowed applications.

    Judging from your questions, I'd say it's safe to assume the latter suggestion is more pertinent to your situation.

    **P.S.
    Also, the tutorials so far are quite...... well......lets say the long and harder way made.,
    I severely doubt you are in any position to judge the tutorials. If you don't like them, find some other tutorials; but if you find that every tutorial is too "the long and harder way", then PERHAPS the problem does not lie with the tutorials.
    Last edited by Hunter2; 03-21-2005 at 03:52 PM.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  11. #26
    Registered User DDX's Avatar
    Join Date
    Mar 2005
    Posts
    29
    Quote Originally Posted by Hunter2
    Judging from your questions, I'd say it's safe to assume the latter suggestion is more pertinent to your situation.
    true....but is there also a program which outputs the code source of another program?

  12. #27
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    In assembly, perhaps. But you won't be able to make anything out of it unless you understand assembly, which you don't.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  13. #28
    Registered User DDX's Avatar
    Join Date
    Mar 2005
    Posts
    29
    do you subestimate ppl often?

  14. #29
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    No. But people don't often come here asking questions that would be answered by the third page of their textbook.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  15. #30
    Registered User DDX's Avatar
    Join Date
    Mar 2005
    Posts
    29
    uhh ok sorry......i wanted to ask ya to convert this console app in a window....but u wouldnt do it anyway and oh well.............

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 03:30 PM
  2. Create a Program with no window
    By brconner in forum C++ Programming
    Replies: 8
    Last Post: 05-27-2007, 01:26 PM
  3. Window scrollbar
    By maxorator in forum Windows Programming
    Replies: 2
    Last Post: 10-07-2005, 12:31 PM
  4. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  5. Making dialog box the only window
    By PJYelton in forum Windows Programming
    Replies: 2
    Last Post: 09-06-2005, 12:02 PM