Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 1.4 KB

File metadata and controls

26 lines (21 loc) · 1.4 KB

Java-Lab-004

Part 1: SimpleMethod.java

  • Add a method square() to SimpleMethod.java that takes a single argument and prints the result of squaring its integer parameter.

Part 2: SimpleMethod2.java

  • In SimpleMethod2.java, expand the square function to return the result of the square as type int
  • In the main class use System.out and Scanner to request the integer argument you'll pass to the square method.
  • Store the result from square in an integer variable in main and print the result.

Part 3: SimpleMethod3.java

  • Modify SimpleMethod3's square methods to use Math.pow instead of simple multiplying the numbers yourself.
  • Complete both the integer and the double square functions, this is called method overloading!

Part 4: Radians.java

  • Write a method called toRadians that converts degrees to radians without using the Java Math library.
    • HINT: degrees = radians * 180 / PI
  • Write a method called toDegrees that converts radians to degrees without using the Java Math library.
    • HINT: radians = degrees * PI / 180
  • In the main function, compare your method's results to the Math.toRadians and Math.toDegrees methods by printing to the console.

Part 5 - Submission

  • Commit your working code
  • Push it to your Remote/origin branch (i.e. GitHub)
  • Then issue a Pull request to the instructor branch
    • Make sure to save the Pull request URL and submit it for the lab.