MyProgrammingLab Programming Challenge 70036 Part 1 Transcript

Print

Let me help you with the Chapter 12 programming challenge. We'll open this up, and then I'll open up Week 1. And there's Chapter 12. And then there's a programming challenge. 

So this one, you want to ask for two file names. And then one, you want to open it for input. And the second, you want to open for output. And the first file has sentences that end with a period. And then the program reads the contents of the first file and then changes all letters to lowercase except the first letter of each sentence. 

That first letter needs to be made uppercase, and then the revised or the fixed content should be stored in the second file. That's awesome. This is fantastic because this is very much what we do in software industry. 

Because we're looking at input that the user gives us. We look at the data that we read from our sensors. We look at different things. We clean it up, and then we process it. So this is the cleaning it up part. 

So with this right here, it says some instructor notes. "Visual Studio 2013 and 2015 do not require CString." And that converts a regular string into a character constant file. And, "However, older versions do." So code lab requires it. 

So we need to put that in, even though we don't need it for Visual Studio 2015. And maybe code lab will be changed or updated so it doesn't require it in the future. But right now it does require it. So we'll put that. No big deal. 

The next thing is the prompt is actually, must be exactly this. So the prompt has to be exactly like this. And it looks for the word "the". I mean everything has to be exactly like this. And then that's for the input file. And then for the output file the prompt must be exactly like this. So we have to remember to use those exact words and letters and everything, including the space bar after the colon. 

So that's our task, and let's make it happen. I'm going to go ahead and boot up Visual Studio 2015. And my 2015 is right here on my most used. But if yours is not, just hit All Apps. And then just scroll down and then find Visual Studio 2015. There it is. And then just click on it. It boots open. 

With 2015 open, you can click on New Project, or you can hit the New Project icon right here, or you can hit File > New Project. File > New Project, but nobody ever does that because it's just too easy just to hit New Project here or New Project here. 

So I'm going to hit this one. This is my favorite way. And then we want to make sure that Visual C++ is selected. And then you want to hit Empty Project, Empty Project. 

So now I'm going to go ahead and call this "Week 1". And then this is going to be programming or "Chapter 12 Programming Challenge", can you do it? So it's a programming challenge. Can you do it? 

So the location, hit Browse. And go ahead and find a good location for it. I'm just going to save it to my desktop. And then I'm going to hit the OK button. 

So here are the source files. My Solution Explorer is open, but yours may not be. If your Solution Explorer is not open then hit View, and then go to Solution Explorer and that will open it up. 

So with the Solution Explorer, it may also be collapsed like this. And if it is, just hit that little triangle. That opens it up. And then there's my source files. 

So there's nothing in it. If there was there would be a little triangle. So I'm going to right click on Source Files. I'm going to Add New Item. 

And then this is, needs to be a C++ file. So make sure it says "Source.cpp". And you can rename this to whatever you want. No big deal. I'm just going to leave it Source.cpp. 

I'm going to hit Add. And then this is our code file. So up here at the very top, I'm going to say "# include I/O stream". And then I'm going to say "using namespace std". And this is required to do our "cin" and our "cout". 

And then up here at the very top, we really should put our information. So you can put a slash star, and then hit your Enter key. And then everything that's between the slash star and the star slash is a comment. So just right up here, just put your information. CEIS190 and then just a short description. 

So this is going to be cleaning a file. And this will be "Chapter 12 Programming Challenge". And up here, you can put a lot more information. 

And in production you do put a lot more information. You put your phone number, your e-mail address, your company name, the date that you created, the whole works. So I'm just going to do it like this. 

So now down here then, I bring in my libraries. And I need to put entry point to the application. And three slashes like this is called a documentation comment. So a slash star and star slash is called a block comment. And everything in the block is ignored by the compiler. 

Three slashes is a documentation comment. So that tells us what this method does. So I'm going to create my main. 

The reason I'm creating this main, the reason it exists is because it is the entry point for the application. So now I'm going to pause the application just using system pause. And then I need to return 0, like that. 

And there's a lot of different ways to posit. And this version right here requires DOS. So it actually reads down to a DOS command window and types "P-A-U-S-E" on it. So it's not very transportable. But at the same time, just about every way to pause has some problems, has some issues on transportability. 

Now the other way I could do, is I could simply hit Debug, and I could start without debugging. And that way it does pause it automatically for me. But I love my debugger. And debugging, we have to be really good at debugging. So I'm go ahead and just use that. 

So this is my pause. I run it, and make sure everything runs well. And I'm ready for the programming challenge. 

So the first thing I want to do is let's go ahead and create a file so we know exactly where we're going and what's happening. So I'm going to go ahead and open up the folder. So right there is the project that I created. And then I'm going to open up the folder with the same name. So that's this one right here. 

And then right there is a Source.cpp. And this is the default location for files. So I'm going to right click in this folder. Again, look for your Source.cpp. And then right click on the white area. 

And then we're going to hit New Text Document. And then this text document, you can call it anything that you want. I'm going to call it "sentences". 

Let's open that up. And this is the file that we're going to read and we're going to clean up. So I'm going to open this up. 

And let's just put some stuff in here. So I'm going to say this is a sentence. So obviously I'm messing up the capitalization. And then I'm going to put two spaces. And then this is a second sentence. 

And I'll put three spaces, 1, 2, 3, 4. And our application is not going to worry about spaces, but I just want to make sure that we can put 1, 2, 3 spaces, whatever. It's not going to make a difference. Then this is the third sentence. 

And I'm going to hit the Enter key. So I want to make sure that the Enter key also works. So I hit the Enter key to make sure that when we create this application, it's able to handle Enter keys as well. Because files, at the end of a paragraph, you hit the Enter key. 

And then I'm going to say here is the next paragraph. And then I'm going to hit the Enter key. And there we go. So this is what we want to convert. So we want to clean this up. 

The first letter should be capital. And then every other letter should be lowercase. And we need to make sure that once we see the period, the very next character is capitalized. So I'm going to close this down. I'm going to hit Save. 

And let's go back overt to Visual Studio. And let's start working. So the first thing I want to do is I want to get file names from the user. 

And two slashes like this is called a line comment. So when you put two slashes, the balance of the line is ignored by the compiler. So when you actually compile it into machine code, all your comments are ignored completely. 

And they have no effect whatsoever on the file size. So you want to put good commenting so people know what you're doing and they can update your code effectively. And that's a very important thing to know how to do and to do.

[End of Audio]