When Using this code: import java.util.Scanner; public class Main { public stati
ID: 3917259 • Letter: W
Question
When Using this code:
import java.util.Scanner;
public class Main
{
public static double perimeterRectangle(double length, double width)
{
double perimeter; // variable declarartion
perimeter=2*(length+width); // Find perimeter of rectangle
return perimeter; // return perimeter of rectangle
}
public static void main(String [] arg)
{
Scanner keyboard=new Scanner(System.in);
double length, width,perimeter;
System.out.printf("Please enter length of rectangle:");
length=keyboard.nextDouble(); // Accept length
System.out.printf("Please enter length of rectangle:");
width=keyboard.nextDouble(); // Accept width
perimeter=perimeterRectangle(length, width); // calling function
System.out.printf("Perimeter of rectangle is %.2f ", perimeter); // print perimeter of a rectangle
}
}
Or this code :
Explanation / Answer
ScreenShot
----------------------------------------------------------
Note:-
----jGRASP exec: java Methods2
Hello from main
Please enter number one:12
Please enter number two:15
The result is 13.500000
Perimeter of Rectangle is 54.00
----jGRASP: operation complete.
----jGRASP exec: java Main
Please enter length of rectangle:15
Please enter width of rectangle:14
Perimeter of rectangle is 58.00
----jGRASP: operation complete.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.