Call the method to calculate the area of the rectangle
•
Java
The code is as follows:
import java. util. Scanner; Public class demo {public static void main (string [] args) {system.out.println ("= = calculate rectangular area = ="); system.out.println ("please enter length:"); scanner SC = new scanner (system. In); float a = sc.nextflow(); system.out.println ("please enter width:"); / / scanner SCB = new scanner (system. In); float B = sc.nextflow(); system.out.print ("rectangular area:") ; System. out. println(getArea(a,b)); } public static float getArea(float width,float height){ float area=0; area=width*height; return area; } }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码