Skip to content

Instantly share code, notes, and snippets.

@amrojjeh
Last active May 23, 2021 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amrojjeh/4be73170b1d8bf7a044e44cbc5a68c15 to your computer and use it in GitHub Desktop.
Save amrojjeh/4be73170b1d8bf7a044e44cbc5a68c15 to your computer and use it in GitHub Desktop.
Classes - Main Code after basic point
public static void main(String[] args)
{
// (2, 3)
double x1 = 2;
double y1 = 3;
// (5, 0)
double x2 = 5;
double y2 = 0;
// p1 + p2
double x3 = x1 + x2;
double y3 = y1 + y2;
// (20, 30)
double x4 = 20;
double y4 = 30;
// (24, 30)
double x5 = 24;
double y5 = 30;
// p5 - p4
double x6 = x5 - x4;
double y6 = y5 - y4;
String output = String.format("(%.2f, %.2f) + (%.2f, %.2f) = (%.2f, %.2f)", x1, y1, x2, y2, x3, y3);
String output2 = String.format("(%.2f, %.2f) - (%.2f, %.2f) = (%.2f, %.2f)", x5, y5, x4, y4, x6, y6);
System.out.println(output);
System.out.println(output2);
// Output:
// (2.00, 3.00) + (5.00, 0.00) = (7.00, 3.00)
// (24.00, 30.00) - (20.00, 30.00) = (4.00, 0.00)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment