Circle functions not behaving as expected in Java Class -


So I created circle set to radius, and if radius, perimeter and area are produced, then if i Input radius, radius, perimeter, area is not returned out, it shows only as 0.0 my circle. Java

  public square circle {private double radius; Private Double PI = 3.14159; Public Zero Satradius (Double Rod) {Radius = RAD; } Public double getRadius () {Return radius; } Public Double GetArea () {Return PI * Radius * Radius; } Public Double Mill DIFFighter () {Returns 2 * Radius; } Get Public DoubleCommentation () {Return 2 * PI * Radius; }}  

and heres circledemo.java- formatting did not come here well

before I input the radius, but when I getRadius, perimeter, area, call it only Output 0.0

Through program execution, step by step. First of all, you start some variables and then create a scanner object. After this, when you enter while loop, you display the main menu, read the input from the keyboard, Create a new circle object , and after that Take care of the input you received.

Anything strange here?

A variable is present only inside the scope it was declared, and your circle object inside < / Em> while while loop was declared. Remember, the loop body shows the loop of a walk for a while, so basically, your circle object is being created again and again This is the reason why setRadius () has no effect.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -