 Unlike my normal videos, which are very highly scripted, I'm going to do this one totally live coding. So there may be a lot of errors, I may have to do a lot of edits, and you're going to see the process as it actually happens. Here's the pseudocode that I developed over the previous video and now I need to make a working program out of it with all the features that I want. Step one for me is to get a program that works period. Once it works then I can start adding the extra stuff later on. So for example on this read the age and make sure it's in the range 0 to 130. For right now I'm just going to read the age and make sure that that part works. I'm going to put up the prompt which according to my document here should say enter customers age or 0 to quit and then I need to do a scan F into the age variable. Similar thing here for reading the day of the week. I need to print out the prompt which is enter day of week with 1 equals Monday, 7 equals Sunday, and then do a scan F into day. Calculating the ticket price based on the day I'll leave that till later. I'll leave all this error checking here and here until later. For what I have now everything should compile and work. Well let's find out. Let's do a build and see what happens. It compiles successfully and let's run it. So if the customers age is 25 ticket price is $8.00. I get to do another age let's put in 12 and now it's asking for a day of week I put in a 4 let's say the ticket price still says $8 because I haven't changed any of that code yet. That's okay I just want to see the programs working in general. Is my do while loop working? Well let's try that out. Put in a 0 and the program should end and it does. So things are looking good at this point. I'm happy with the results so far. Well not entirely. I would really like to have an extra blank after where it excuse me an extra blank line after where it says the ticket price. So what I'm going to do here is I'm going to put in a printf of backslash n give a blank line for spacing and readability. Let's rebuild it and run it again just to make sure that works. So if the customer's age is 12 day of week is 3, price is 0, customer's age is 74, prices is $8.00. Okay that's looking perfectly nice. This is probably the next easiest thing to do. Calculate the ticket price based on what day it is. We've done that if statement before. Namely if the day is equal to 6 or the day is equal to 7 a weekend then the price is $6.00 on all the other days of the week the price is $4.50. Again this is the way I develop programs. I don't try and write the whole thing at once. Every time I add something new I test it with that new thing to make sure that things are still going all right. Let's build and run this up here a little bit on screen. If the customer's age is 29 costs $8.00. If the customer's age is let's say 14 and they come in on a Saturday it's $6.00. If they're 14 and they come in on Monday ticket price is $4.50. So that's all working. The part that isn't done yet is this error checking to make sure that something's in the range 0 to 130 and making sure that it's in the range 1 to 7. That turns into a do-while loop. So I'm going to have loops inside of loops here. Let's think of what has to happen here. I definitely want to do this part. I want to read the age. And I want to do this as long as I have bad data. So as long as you give me something that I can't handle I have to keep this is one of the things I'm going to keep asking you until I get an answer that I like. What's my condition? Well as long as the age is less than zero or the age is greater than 130 that's bad data. I can use that here as well. If the age is less than zero or the age is greater than 130 then I can print an error message. Age must be in range 1 to 130 or zero to quit. And I need to backslash end there. So now I took that single printf and scanf, wrapped it into a loop so I can repeatedly ask for input until I get something that I like. It builds properly. Let's run it and now let's put in a negative 2. Perfect. If I put in something like 150 what about 131? Excellent. If I put in the customer's age as 1 then everything works as normal. Good. That part's working. I have to do something similar here for the day of the week for Monday through Sunday. This code here is going to have to be wrapped into a do-while loop also. I'm going to keep doing this until I get an answer that I like. So I have to keep doing this as long as the day is less than 1 or the day is greater than 7. That's bad data I have to ask again. And similarly here I'll use that same condition in my if statement. If the day is less than 1 or the day is greater than 7 then I'll print my error message which says day of week must be in range 1 through 7 and let's build that and run it. If I give an age like 14 and I put in a negative 1 for the day or a 0 for the day or an 8 for the day won't let me do it. I have to have something that's in range. I want to check at the limits. I want to check with 1 and 7. I want to make sure they didn't accidentally say that 7 was a bad data element. It turns out good. 7 works fine. Let's check to see that 1 is still valid. 1 is still valid so it looks like things are working fine now. Oh there's one thing I didn't test. I have all this stuff at age less than 16. None of that affects the situation when the age is greater than or equal to 16 and theoretically that should still work but I'm paranoid and I'm going to check it anyway. If somebody is 49 okay good the ticket price still works great and now I have the program working exactly the way I wanted to the way I planned it. The only thing I might want to do here is change the error message for age. If the age is less than 0 I might want to have one message for hey you can't give me negative numbers and if it's greater than 130 I'm going to say hey that's way too big. So I want two different error messages for the two different kinds of age errors you might make. Now what I'm not going to do is I'm not going to get rid of the code that's already there. Instead what I'm going to do is I'm going to put it into a comment. C will ignore it but it's still going to be in the source code. That way in case I screw something up completely and my two error message code doesn't work no problem I can always go back to this old code by removing the slash star and star slash. No harm no foul as they say. So what I'm going to do now is I'm going to say okay if the age is less than zero then I have no negative numbers otherwise if the age is greater than 130 that's just unreasonable. There's my pseudocode again I went sort of to the pseudocode stage to cement into my mind that yeah this seems like the right approach and now I'll replace that with the actual error messages. Age cannot be negative and here sorry but we allow a maximum age of 130 only. That's not the best English I've ever written and maybe I can come back later and edit it make it sound a little better but for now it'll do. Let's save that build it and run the program again and this time if I give a negative two age cannot be negative if I give something that's way too big and again I'll test the limits one and 130 should be allowed and it is. I was about to quit the program but I just realized I didn't try 131. 131 should not be allowed so let me check to make sure that it works at that boundary condition. Always test the boundaries because that's where things can always go a little bit weird for your programs. Cool 131 is not allowed exactly as I anticipated now I can quit the program and there it is finished. At this point if I wanted to I could get rid of this comments here but it doesn't hurt to keep it in. You might be thinking wow this program is really getting pretty long and it's hard to keep it all in my head at once. Hold that thought when we discuss functions later on in the course we're going to see a solution to the problem of having a program that has grown beyond our capacity to keep it all in our minds all at once and that's the process of writing a program. I started with the plan I started with figuring out what should it look like when you run the program then I wrote the pseudocode then I made the code work at the most basic level and then I added all the extra features.