Exercícios de Java #04 - Curso de Java

391.78k views2979 WordsCopy TextShare
Curso em Vídeo
Exercícios disponíveis em http://www.cursoemvideo.com/lesson/primeiro-programa-java/exercicios-04-ja...
Video Transcript:
♫ ♫ Opening Theme Hello little grasshopper, we are back here, in the class of the fourth class exercises What's up? Like the fourth class? You put your hands dirty and made its first program Now I'll show you how to create another program because this is a class exercise, you are now doing practical things we will do practical exercises, but first, let's that naughty solving some exercises that fell on the evidence of the Navy or the Air Force So as I said before, this is the Exercises Lesson Lesson 04 Course For Beginners Java where we saw our first program was the "Hello, World.
" Aapenas recalling: the Educandus is the company that brings the Course In Video exercises for you and she is a Training Center specializing in military tenders and tenders So, for your little grasshopper case what else will interest are the courses EAGSsin and CAPpd If you do not know more details about it, I talked about these two segments in the previous three lessons, if you got now, check this out And I said you can be Sergeant of the Air Force, Navy or Cable and work directly with computer. The 1st question is, he wants you to identify the option that contains the value X variable, the final value of variable X, after the end of the implementation program segment that this one side, and it gives you some information A = 3; B = 2; C = 8; D = 7. You'll have to use these values ​​here side to find the value of X The tip I give to you is: always start by relational operators the expressions We will first in the relational values, and then we go to the logical operators If you have any difficulty or problem in relation to operators you have to watch the algorithm Course So well, I just to prepare you for what's coming in Java Course But you will say, "Oh, but he did not speak about it yet!
" I'll talk more forward and you need to know all what I'm talking about here So my dear, gives a studied case you have problem with that But we will solve the exercise, will your idea lightens here So let's start with the relational operators I'll mark blue So I have here A is larger than 3? the A is worth 3 if you see here Then A is larger than 3? No, A is equal to 3, then False The next B is less than 5?
B is worth 2, 2 is less than 5, then True It has more down here, relational operators A is equal to or larger than 2? A is 3, it is greater than or equal to 2, then True The next C is less than or equal to 1? The value of C is 8, C is not less than or equal to 8, then False It has two more down there A is equal to 2?
In my case here, A is equal to 3, then False, A is not equal to 2 The last: B is smaller than 7? B is worth 2, 2 is less than 7, then True Tranquilinho? So, you will go first to the relational operators we've done all, in fact you did not have to do all but as I am with time to do these exercises I'll do it step by step for you Now we will go to the logical operators which are: and; or; no; and we have to first make all the "no" The "no" it reverses the value, then it is false, the "not false" turns "Verdaderio" If it is true, the "not true" becomes "false" He says the following: enter the option that contains the final value of variable X .
. . So I want to know the final value of X in the algorithm that is here on the side and that it give me the values ​​of A, B, C and D A = 3; B = 2; C = 8; D = 7 What we will begin to do, and start working with the relational operators I'll mark here blue I have operators: higher; smaller or greater; less or equal;.
equal; all these are relational operators So I have to do the following: the first here it is checking if A is greater than 3 A is larger than 3? No, A is equal to 3, so this here is False B is smaller than 5? B is 2, 2 is less than 5, True A is greater than or equal to 2?
o is 3, 3 is greater than or equal to 2, then true C is less than or equal to 1? No, C is 8, 8 is larger than 1, so that here also is false The next, A is equal to 2? A is equal to 3, then it is not equal to 2, then False and lastly, B is less than 7?
B is 2, 2 is less than 7, True Tranquilinho? So far so good right? If you have some problem with the operators back in the algorithm class We'll go now to the logical operators are: and; or; or exclusive; no; in the case here I have: and; or; and not; I'll start by all "no," the operator "not" it makes the inversion of logic value So I'll mark green here, I have no one, I have two operators not They will reverse the value that is immediately after he So I'm here, 'not false' will be 'real' 'Not true' will be 'False' I do not have any "no", is finished here my operation From here I go "and" and the "or" In the first case here I have True and False, True and False, I'll put another color here will give False The result is yellow In the following case here, True or False True or False will give true, also made of yellow Finally here, False or True, it will also give True We've done here all logical operators and all relational operators Now just starting to embrace, and to know which X will be solved here So what I have is the following: if I have this "if", and it is false, I will not run "then," I'm going to "save" So here it is false, that "if" resulted here in yellow, False So this is here it will give False, then I will not run X gets 10, I will leave for the "but" and I have another "if", we'll see what he saw Chi run This one has true, then it will run the "then" He saw ignore the "but", so we made this part down here totally without This bottom it will not be executed The command that will be executed is exactly that I will score here X receives the most D divided by 2 Then my will receive X A which is 3 plus D, which is 7, all divided by 2 Solving this quickly I have X via avail 3 7 more equal to 10 divided by 2 equals 5 Final answer, letter B Did you see how simple it is?
So it is only you control, it's just you see what's happening and bring it on, you will get So the issue here, it is difficult? No, it is simple, it fell in Aeronautics You can become an Air Force Sergeant solving such questions You do not know how yet? at the end of this video I talk to you again my little grasshopper And speaking of expression, I brought another issue here that crashed in Aeronautics he says the following: Tell alternative that has the representation in the form of arithmetic expression below: So the expression is here, and I want to represent it mathematically.
This would look like this . . .
5 squared, divided by 32 minus 13, all over 8. 2 Right? This is the expression that I want to represent Z is equal to it here How am I supposed to represent in this algorithm?
To represent this in algorithm I'll do Z receives, then it is a small arrow, I have to do 5 squared 5 squared I can do in two ways, or 5 times 5, which is 5 squared 5 circumflex or 2, which is squared 5 or I can turn this caret a small arrow up whatever, any of them will serve I have I divided by 32 minus 13 Basically if I leave it that way, I'll have problems with the order of precedence So what I will do here is to put the two brackets as I want it all over 8. 2, which I have to do? I'll have to put it all into another parenthesis and finally we do sum it all by 8.
2 The option that has that answer is the alternative D Man, you never thought it would be so simple to join the Navy or the Air Force, is not it? So therefore, I'm not selecting only simple exercises not He has several years in the Navy and the Air Force You will get in touch with the guys from Educandus, they will give you some evidence so you can take a look, and you little young, you who are between 17 and 25 years you can enter in the military, and you will not be carrying weight, get the gun, stand in the rain you will be Officer of the Navy or the Air Force, and working with computer this is sensational! And speaking of amazing, in this class we did the "Hello, World" and I promised you at the beginning of class, we have practical part?
We will have practical part. Then there opens your NetBeans, which has something new to show you there open your NetBeans, there is a way to open on your system if you have Windows, Linux if you, you know how to use a system So come on He opened NetBeans, and we will create a new project here this new project we create, how you watched the lesson now on Monday clicking the yellow little button (new project) So we will create a Java project, Java application, which has been marked next, we put here the project name, I'll call here: HoraDoSistema Remembering during this class you saw, the first capital letters indicate class name we'll keep the "create the main class" marked so we can have public static void main end it will already create my main class with the necessary code for it You can delete this code here, but we'll leave here We will do the following: what I want to do is a program to display the current date and system time What I'll do is this, I have a specific class of Java Call Date. So I have the Date, and I'll have my date equal, I'll put new Date opens and closes parenthesis point-and-comma And you'll see that Java will give an error, NetBeans actually gave an error he says he does not recognize the word Date But if you click here in the tiny bulb and just click and it's there to add import Java.
util. Date which is basically the class I need is the library to date treatment Be careful you do not click java. sql.
Date, which is the date of treatment for Data Bando In the case here I want java. util. Date You will see more details about library import next week on Monday class By clicking here, you realize that he added this line import java.
util. Date; and now I do not have any more mistakes Basically what I'm doing here now is as follows: when I use the word "new" using the new word I'm creating a new object Learn it as soon as later on you will hear much I talk about it Then you will put Date, boot the name you want, I put date I call for example "watch", we call clock that is better then watch is my object, how do I know that watch is my object? Why has the new word after him What I can do is this: we will write on the screen, as taught in class salt and press the Tab key, without pressing the "space" Tab, he has filled I'll write: "The system time is" I'll do another salt here other System.
out and I will put First remove the quotes, so lets and places clock, no please accent, point, boot a point that we will have a method, I talked about method in this class also You will put a method begins with a lowercase letter toString You see here, NetBeans makes it easy for you, convert, he has an explanation yet converts this "data" object to a string that is what I want Give enter, already selected, as was And oh my darling, just use your magic finger and press play look what will happen . . .
The system's time I'm recording this video on March 4 at 7 am Yeah . . .
and you finding there that I'm sleeping at 6 am, I tó from 6 hours recording then there're the proof that I'm working early And then, like it? The Course In Video Exercises and exactly for that to show something that I did not show during class and to do a little more exercise complicadinhos For example, now I'm going to let a challenge for you, little grasshopper which is to make this the other two programs you will search the internet, you will see how it works and if by chance you do not understand no problem, it is a challenge that I'm doing for you See here on the left that magically appeared two projects I created and I to leave hidden from you, for you can not copy. This one he will do next, I'll play: select here, click here Tightening the play it will show: your system is in Portuguese.
Man, I managed to get the operating system language using the Java It will say that this language is not "poderosinha" Woe to you? It does more things than many others out there Is the last it will take the resolution of my screen Then I'll squeeze play Its screen has 1280 x 720 resolution which is the standard resolution, 720p that is the one that we use in the Course In Video, that resolution naughty so you can see even in their giant TV, 720p with 60 frames per second only the Course In Video that brings it to you How many courses do you know on the Internet where behind a quality 720p 60 frames per second? It is the most fluid course you know, you can see my ugliness in every detail So that's my little grasshopper these are the two challenges that I brought you He was confused, did not understand right, you go there in the Course In Video cursoemvideo.
com there you will have all the packages, including the exercise package Lesson 04 where is the response of these two exercises So my dear, research before you try to make your not ahead you want to copy Why is this, you will turn program player no one is in need of those who can read program tá needing maybe do Then there research on the internet, the answer is not so hard to find research and try to do this exercise just like I did this here And as always to finalize Are you sure? It is with questions regarding the tender Navy and Air Force? You can talk to the guys from Educandus To do this you can access the site, the site has a lot there but if you have a specific question, or if you simply want to thank the exercises comes in contact with the guys, and you should already know the color email if you do not know will show again send an email to: fale@sistemaeducandus.
com. br there the guys will certainly help you they will answer your question It may be it takes a little bit because the avalanche of locusts is giant It is a galley that is directly talking to the crowd of Educandus It is really cool this interactivity of you with the guys Still wondering whether more details will there talk to the guys, they will be able to help you more than I even So my dear this is the email: fale@sistemaeducandus. com.
br boot in your list of email favorites, sends a message the guys they are prepared there to meet you And that my dear, from now we here next week, on Monday has class and Wednesday has exercises and usually on Friday or Saturday, you have the Course In Video Answers So guys you're creating a lot of content contents as Course in Video never created What I need is for you to continue enjoying, sharing, showing friends this kind of thing is valuable to me This sort of thing is valuable for the channel Do not let the channel be forgotten "Oh, I do not get it right the first class I will not do more" and there goes away, no! Signs the channel, enjoys the classes, persist little grasshopper nothing in life is easy and you there thinking it would be easy to learn Java It's not easy, I will always bring challenges here for you and you have full capacity, I believe in you, I trust you I'm talking about looking at you, I trust you, you will learn Java You will learn even That's right my dear, Monday we'll see you on Wednesday we'll see you again Friday . .
. I see you more than your own family Sincerely, studying my dear, good practices and to the next.
Copyright © 2024. Made with ♥ in London by YTScribe.com