‫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 pause the video and think about how to write such a program in Kotlin.
‫And by the way, I am waiting your solutions in the comment below.
‫So copy and paste your solutions and I can help you if there is an error or any mistake.
‫Let's create a new project in Android studio.
‫I choose a new.
‫Or no, no activity.
‫I will name my project Kotlin exercises.
‫And the language is Kotlin.
‫I click on Finish and everything should be working fine waiting Android studio to set up the project
‫and generate the gradle build.
‫Then let's go to the app Java Kotlin Exercises.
‫I need to create a new Kotlin file here.
‫I will name it as exercise.
‫Okay.
‫And in inside this exercise I will create one main function.
‫And here we start writing our codes.
‫I hope you paused the video and think about this exercise.
‫How to get input from the user, how to get the division and the remainder of these two numbers.
‫So I will start by creating and getting the numbers from the user.
‫So I will create a Var scan or S1 equal to scanner object.
‫Okay.
‫And here I will use system dot n.
‫This is how we get the input from the
‫user.
‫Okay, we use the scanner object.
‫This is an object that we will use later on in the next lines, but I need to print for the user a message
‫telling him please enter.
‫Our number.
‫Then I will var x equal to s one dot next int.
‫Next end is used to get the input.
‫The integer input of the scanner of the input user.
‫So the user enters, X enters five, for example, it will be storing five inside this variable x.
‫So in this case we have introduced and learned about how to get the input from the user by using the
‫scanner object.
‫Okay.
‫And var.
‫Let me print again here.
‫Please enter.
‫Second number.
‫Var y equal to s1 dot next int.
‫Okay.
‫So I need to get the first two numbers and I will divide them by creating here.
‫Var result is equal to x over y and var thus the division or div I will name it as div result.
‫And here the var of remainder equal to x.
‫Modulo y.
‫So you remember the modulo.
‫This is the operator for this and getting the remainder of the division.
‫So for example, if x equal to ten and five is Y, then ten over five will be will give us the division
‫result equal to two, while the remainder will equal to zero because there is no remainder in this case
‫print.
‫The remainder or the division, the result equal to div result and the remainder is.
‫Um, as a reminder.
‫Okay.
‫This is the variable reminder.
‫So this is the program.
‫Now, let's run the program and see.
‫I choose here exercise to run the program.
‫Don't miss it.
‫Writing for the program.
‫And here we go.
‫Please enter the number.
‫I will enter ten.
‫Please enter the second.
‫Number five.
‫The result is equal to two and the remainder is zero.
‫Congratulations guys.
‫We have successfully created this program and we introduced and learned about the scanner, how to use
‫the scanner, how to get the input from the user and display the result of the division and the remainder.