Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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); //

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 :

import java.util.Scanner; public class Methods2 { public static double average(double p1, double p2) { double ave; ave=(p1+p2)/2; return ave; }//end of average   /**  * this method will return the perimeter of rectangle  * @param p1  * @param p2  * @return perimiter of rectangle  */  public static double perimeter(double p1, double p2){ return 2*(p1+p2); }//end of perimeter   public static void main(String [] arg) { System.out.printf("  Hello from main"); Scanner keyboard=new Scanner(System.in); double num1, num2; System.out.printf("  Please enter number one:"); num1=keyboard.nextDouble(); System.out.printf("  Please enter number two:"); num2=keyboard.nextDouble(); double result; // the average is called // the return value is assigned to "result"  result=average(num1, num2); System.out.printf("  The result is %f", result); // calling the perimeter method with sides  double perimeter = perimeter(num1,num2); System.out.printf(" Perimeter of Rectangle is %.2f  ",perimeter); }//end of main  }//end of Methods2 I Get this error message in JGrasp "compilation failed but no errors were detected. Check for non clickable errors in the compile output" any fix on either code so it will work on Jgrasp for my homework?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

This element is used to link to an external style sheet:

Answered: 1 week ago