Difference between revisions of "CISC181 S2017 Lab1"

From class_wiki
Jump to: navigation, search
(Created page with "* [http://developer.android.com/sdk/index.html Download Android Studio] and install it on your machine ** [http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloa...")
(No difference)

Revision as of 10:04, 13 February 2017

  • Download Android Studio and install it on your machine
    • Java JDK 7 is a system requirement
    • JRE is a system requirement on Mac OS X. However, this worked where JRE alone didn't
  • Either on your machine or on an eCalc machine in lab:
    • Make a new project following these instructions
    • If you haven't already, paste the following into MyClass: public static void main(String[] args) { System.out.println("Hello, world!"); }
    • Confirm that you can build and run it (by pressing the green triangle button or choosing "Run" from the Run menu)
  • Modify MyClass.java as follows:
    • Add your name and section number as a multi-line comment
    • Using a single-line comment, disable the "Hello, world" print statement in main()
    • You will use main() to compute several geometric identities involving a general triangle with sidelengths a, b, and c as shown below. Declare these variables as double, prompt the user to enter them, and read each in using the Scanner class.

      • Heron's Formula gives a method to compute the area A of the triangle. Follow the link and use the first formula to derive the semi-perimeter s and A from a, b, and c; implement it using Java math expressions and/or functions; and report both s and A with System.out.println().
      • The Law of Cosines can be used to calculate the angle γ (gamma) between a and b (second formula in Applications section of link). Math.acos() will give the angle in radians; please convert it to degrees and report it with System.out.println()
      • You might notice a lot of decimal places printed in your answers. Change your println() to format as necessary to only print 2 digits after the decimal for s, A, and γ.
      • Use proper naming and formatting style throughout your code.

Submit your MyClass.java on Sakai by Friday, February 17