Bawnawgwa's Profile User Rating: -----

Reputation: 6 Worker
Group:
Active Members
Active Posts:
130 (0.18 per day)
Joined:
21-January 13
Profile Views:
794
Last Active:
User is offline Jan 29 2015 10:20 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   Bawnawgwa has not set their status

Posts I've Made

  1. In Topic: Intro to C help. printf, scanf. Probably Basic things

    Posted 27 Jan 2015

    View Post285matt, on 26 January 2015 - 01:55 PM, said:

    I've gotten a bit further, but have no idea how to write the specific amount of dollars and change separatel.
    #include <stdio.h>
    #define ticket 8.75
    int main(int argc, const char * argv[]) {
        int can, i;
        float have;
        for (i=0;i<1000;i++){
        // insert code here...
        printf("Welcome to The Riverloo Cinemaplex.\nHow much money do you have?\n");
        scanf("%f", &have);
        printf("You have entered $%.2f\n\n", have);
         if (have < 8.75)
          printf("This can purchase 0 tickets, leaving you with $%.2f.That is %d dollars and %d cents change.\nThank You.", &have); //Don't //need the & there, also you need two other variables for the dollars in cents so it would be: blahblahblah", have, dollars, cents);
        
         if (have = 8.75)//in if statements, you MUST use '==' to test for equality, not '='
            printf("This can purchase 1 ticket, leaving you with $0.\nThat is 0 dollars and 0 cents change.\nThank you.");
        
         else if (have >= 8.75)//Get rid of '=' here because you tested for equality already, so just make this condition for >/
    //Also, bracket everything you want in your if, else-if, for loops etc. 
             can = have/ticket;
    //This print statement is not in the else if() condition, which I believe it should be? Could be wrong though. thus, this will always //print since it is outside of any condition, it will always hit it in the loop. Again, here you need variables for each %d or %f you //include in the text.
        printf("This can purchase %d tickets, leaving you with $%d.\nThat is %d dollars and %d cents change.\nThanks you.\n", can);
                  
        }
        return 0;
    }
    


    I have added comments to things I saw to help fix the code. This should help get things in the proper order.

    Oh, and why do you have a for loop running 1000 times? It might be better to use an infinite while loop and add a break condition. Like if the user enters 'q' or something to break out of the while loop and end the program. Otherwise to complete the program the user is forced to run it 1000 times, and if it is needed more than 1000 times, they will have to restart it. an infinite while loop can be achieved using while(1), but to check if 'q' or something was entered you can do while(ch != q). ch will have to be of type char to test for something like that
  2. In Topic: Dungeon generator generating random extra rooms?

    Posted 27 Jan 2015

    Yay! Thanks Skydiver! With your rand() debugging help I fixed two problems that were plaguing me. The random extra rooms/walls, and rooms occasionally getting too close together! Now that it functions properly I can clean it up :P
  3. In Topic: Dungeon generator generating random extra rooms?

    Posted 26 Jan 2015

    Haha jeeze, it posted my comment three times! I clicked post comment and it loaded forever and took me to a 505 error or some such :/. Sorry about all the reposts hehe. But thanks again Skydiver for the pseudocode! Your tips should be a ton of help in fixing my generator :P
  4. In Topic: Dungeon generator generating random extra rooms?

    Posted 26 Jan 2015

    Alright, thanks for the help! I will make the adjustments with the random number. Our max boundaries are 160 (x) and 96 (y). Since that is all it will and shall ever be I thought why not just use it. But sorry, I should have mentioned, I am using C only, so do not have the OOP available to C++.
  5. In Topic: In regards to reading variables and their values from files

    Posted 14 Apr 2014

    Thanks CasiOo! the trim and split worked like a charm :)

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

Bawnawgwa hasn't added any friends yet.

Comments

Bawnawgwa has no profile comments yet. Why not say hello?