‫Hello my friends, and welcome to coding Exercise number two.
‫Write a program that gets from the user the radius and print the area and parameter of the circle.
‫I want from you to post the video and think about how to solve such a program.
‫I hope you solve it correctly.
‫Now, let's see the solution.
‫In order to get data from the user, we use the scanner.
‫So scanner SW one alt plus enter to import the package of the scanner.
‫And here we have import the java duty of the scanner equal to new scanner system.
‫I told you to memorize this.
‫Well in order to get data from and input from the user now.
‫I should print for the user a message telling him that I need a radius.
‫Please enter a radius.
‫S1 or a radius or int or radius equal to.
‫S1 dot next.
‫And so we need to get integers.
‫Now I want to display the perimeter.
‫So perimeter and P or float equal to 30, equal to pi to.
‫Times PI, which is 3.14 times radius and I need to display the area.
‫So area equal to pi, which is 3.14 times.
‫Radius times radius again, this is the radius square.
‫I'm casting them to float.
‫And this is the float.
‫And you're cast to float?
‫Yes.
‫I asked them to flood this.
‫This is the radius and.
‫This is the radius square.
‫Now, I can display like this system without the print, and the area is equal to plus area and.
‫Perimeter is equal to perimeter object or perimeter.
‫Valuable.
‫Let's run and see.
‫Again, I need to run with coverage.
‫So here I enter the radius, I will enter to click enter.
‫The area is 12.56 and the perimeter is 2.56.
‫Let me run again with.
‫With the coverage entering the radius five.
‫The area is 78.5 and the perimeter is three 31.4.
‫So successfully you did it.
‫We have created this this as this program that calculates the perimeter and the area for a given for
‫a given radius.
‫One note I should mention before we we and I can use math dot and here we use a pi oc.
‫So pi.
‫This is from a class called Math.
‫If I go up.
‫This is included inside the Java.
‫I can use it.
‫Math, dot, dot.
‫I access a pi pi.
‫So if I run the program again with the coverage, I can enter the radius five.
‫It will calculate for me the area with more and more decimals because pi is equal to 3.14 15 926535
‫and so on.
‫This is how we use the math dot p i which is pi.
‫And you can use other things like absolute value, sine, cosine, tangent, exponential power and servo
‫log max, minimum, etc..
‫Okay.