Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. public class KuadratMain {
  2.  
  3. /**
  4. * @param args the command line arguments
  5. */
  6. public static void main(String[] args) {
  7. // TODO code application logic here
  8. Scanner input=new Scanner(System.in);
  9.  
  10. Kuadrat obj=new Kuadrat();
  11. Kuadrat obj1=new Kuadrat();
  12. Kuadrat obj2=new Kuadrat();
  13.  
  14. //obj1
  15. System.out.print("Masukkan a = ");
  16. obj.a=input.nextInt();
  17. System.out.print("Masukkan b = ");
  18. obj.b=input.nextInt();
  19. System.out.print("Masukkan c = ");
  20. obj.c=input.nextInt();
  21.  
  22. System.out.println("Persamaan = "+obj.a+"x^2+"+obj.b+"x+"+obj.c+"");
  23. System.out.println("Titik Potong Dgn Sumbu X1 = "+obj.rumusx1()+ "dan X2 = " +obj.rumusx2());
  24. System.out.println("Titik Potong Dgn Sumbu Y1 = "+obj.rumusy1()+ "dan Y2 = " +obj.rumusy2());
  25. System.out.println("Titik Puncak x= "+obj.puncakx()+"y= "+obj.puncaky());
  26. System.out.println("Sumbu Simetris= "+obj.sumbusumetri());
  27.  
  28. //obj2
  29. System.out.print("Masukkan a = ");
  30. obj1.a=input.nextInt();
  31. System.out.print("Masukkan b = ");
  32. obj1.b=input.nextInt();
  33. System.out.print("Masukkan c = ");
  34. obj1.c=input.nextInt();
  35.  
  36. System.out.println("Persamaan = "+obj1.a+"x^2+"+obj1.b+"x+"+obj1.c+"");
  37. System.out.println("Titik Potong Dgn Sumbu X1 = "+obj1.rumusx1()+ "dan X2 = " +obj1.rumusx2());
  38. System.out.println("Titik Potong Dgn Sumbu Y1 = "+obj1.rumusy1()+ "dan Y2 = " +obj1.rumusy2());
  39. System.out.println("Titik Puncak x= "+obj1.puncakx()+"y= "+obj1.puncaky());
  40. System.out.println("Sumbu Simetris= "+obj1.sumbusumetri());
  41.  
  42. //obj3
  43. System.out.print("Masukkan a = ");
  44. obj2.a=input.nextInt();
  45. System.out.print("Masukkan b = ");
  46. obj2.b=input.nextInt();
  47. System.out.print("Masukkan c = ");
  48. obj2.c=input.nextInt();
  49.  
  50. System.out.println("Persamaan = "+obj2.a+"x^2+"+obj2.b+"x+"+obj2.c+"");
  51. System.out.println("Titik Potong Dgn Sumbu X1 = "+obj2.rumusx1()+ "dan X2 = " +obj2.rumusx2());
  52. System.out.println("Titik Potong Dgn Sumbu Y1 = "+obj2.rumusy1()+ "dan Y2 = " +obj2.rumusy2());
  53. System.out.println("Titik Puncak x= "+obj2.puncakx()+"y= "+obj2.puncaky());
  54. System.out.println("Sumbu Simetris= "+obj2.sumbusumetri());
  55.  
  56. }
  57.  
  58. }
  59.  
  60. public class Kuadrat {
  61.  
  62. double a, b, c;
  63. double y;
  64.  
  65. double d(){
  66. return (Math.pow(b, 2)-(4*a*c));
  67. }
  68.  
  69. double rumusy1(){
  70. return a*Math.pow(rumusx1(), 2)+b*rumusx1()+c;
  71. }
  72.  
  73. double rumusy2(){
  74. return a*Math.pow(rumusx2(), 2)+b*rumusx2()+c;
  75. }
  76.  
  77. double rumusx1() {
  78. return ((-b + (Math.sqrt(Math.pow(b, 2) - 4 * a * c))) / 2 * a);
  79. }
  80.  
  81. double rumusx2() {
  82. return ((-b - (Math.sqrt(Math.pow(b, 2) - 4 * a * c))) / 2 * a);
  83. }
  84.  
  85. double puncakx(){
  86. return -b/(2*a);
  87. }
  88.  
  89. double puncaky(){
  90. return (d())/-4*a;
  91. }
  92.  
  93. double sumbusumetri(){
  94. return (-b)/2*a;
  95. }
  96.  
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement