‫Hello my friends, and welcome to coding Exercise number one.
‫In this exercise, we are asked to write a program that gets from the user to numbers and displays their
‫division and remainder.
‫I want from you to post the video and think about how to solve this exercise.
‫I hope you solve it correctly.
‫So let's start solving this exercise.
‫Since I need to get data from the user, I need to use the scanner scanner object in equal to new scan
‫and we put system dot in.
‫I want from you to understand this for now.
‫Like.
‫You.
‫You memorize how to get data from the user, how to get input from the user using the scanner.
‫Don't worry.
‫Please write it down in order to memorize it later on in the next exercises.
‫But it's very simple.
‫I use the scanner in what I can make the S1 scanner as one, and here I will display for the system
‫for the user, a system that output print l n a message telling him to input or enter the first number.
‫As one int.
‫Number one equal to SX one dot next.
‫And this is how we get the variable DN one.
‫This is how we get from the scanner waiting for the input of the user and restore the input of the user
‫inside a variable called and one number one.
‫The same way, I need to display another message telling the user to enter the second number.
‫And number two equal SW one, which is the scanner next and we use next int for getting the integers
‫we can use next line in order to get the strings to return strings.
‫And we can get next byte for by next end.
‫Next line gets a get the short get by get boolean and so on.
‫So we use the scanner in order to get the input from the user.
‫Now when we get these two numbers, we need to display their division and their remainder.
‫So system it out.
‫I can store them inside a variables.
‫It's better in order to understand them.
‫So int division equal NW one over NW to OC.
‫I am dividing in one over empty.
‫But it's better to use the float.
‫So I use float in order to to divide and one over and two because if you divide five, which is an end
‫over two, which is an end, so you get 2.5 which is a float.
‫So sys dot out dot print l and the division.
‫As.
‫Division result as the.
‫Okay.
‫But I can make like this and one over and two equal to the.
‫Again.
‫I need to get the remainder.
‫So float a remainder r equal to n one.
‫We use the modulo here and to.
‫System that out to print the remainder.
‫Equal to plus plus.
‫Ah, let's run this program and see.
‫I Should you go up here and run?
‫Hello, Ward.
‫That man with coverage.
‫Okay.
‫And there we go.
‫We can enter the first number, which is five.
‫Click.
‫Enter.
‫Enter the second number, which is to click.
‫Enter the.
‫The result is n one over and two is 2.0 and not 2.5.
‫We should correct it.
‫The remainder is one.
‫Okay.
‫So the division will gives you the the numbers that the around them how to how divide them because integer
‫over integer will give you an integer despite you are storing them inside a float.
‫So what should I do?
‫I should cast this float to tell that this division I need it as a float.
‫So this is a type casting that we have seen before.
‫So if the IET on the program now, everything will work fine again.
‫Run a little ward with coverage.
‫Enter the first number five and then the second number two.
‫And here we go, the division and one over and two is 2.5.
‫The remainder is one that may run the program again and see if I divide four over to four over two is
‫equal to 2.0, The remainder is equal to zero and everything is working fine.
‫This is how we solve this problem, this exercise.
‫We get the first number, the second number, and we display their division and remind.