Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class KuadratMain {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- Scanner input=new Scanner(System.in);
- Kuadrat obj=new Kuadrat();
- Kuadrat obj1=new Kuadrat();
- Kuadrat obj2=new Kuadrat();
- //obj1
- System.out.print("Masukkan a = ");
- obj.a=input.nextInt();
- System.out.print("Masukkan b = ");
- obj.b=input.nextInt();
- System.out.print("Masukkan c = ");
- obj.c=input.nextInt();
- System.out.println("Persamaan = "+obj.a+"x^2+"+obj.b+"x+"+obj.c+"");
- System.out.println("Titik Potong Dgn Sumbu X1 = "+obj.rumusx1()+ "dan X2 = " +obj.rumusx2());
- System.out.println("Titik Potong Dgn Sumbu Y1 = "+obj.rumusy1()+ "dan Y2 = " +obj.rumusy2());
- System.out.println("Titik Puncak x= "+obj.puncakx()+"y= "+obj.puncaky());
- System.out.println("Sumbu Simetris= "+obj.sumbusumetri());
- //obj2
- System.out.print("Masukkan a = ");
- obj1.a=input.nextInt();
- System.out.print("Masukkan b = ");
- obj1.b=input.nextInt();
- System.out.print("Masukkan c = ");
- obj1.c=input.nextInt();
- System.out.println("Persamaan = "+obj1.a+"x^2+"+obj1.b+"x+"+obj1.c+"");
- System.out.println("Titik Potong Dgn Sumbu X1 = "+obj1.rumusx1()+ "dan X2 = " +obj1.rumusx2());
- System.out.println("Titik Potong Dgn Sumbu Y1 = "+obj1.rumusy1()+ "dan Y2 = " +obj1.rumusy2());
- System.out.println("Titik Puncak x= "+obj1.puncakx()+"y= "+obj1.puncaky());
- System.out.println("Sumbu Simetris= "+obj1.sumbusumetri());
- //obj3
- System.out.print("Masukkan a = ");
- obj2.a=input.nextInt();
- System.out.print("Masukkan b = ");
- obj2.b=input.nextInt();
- System.out.print("Masukkan c = ");
- obj2.c=input.nextInt();
- System.out.println("Persamaan = "+obj2.a+"x^2+"+obj2.b+"x+"+obj2.c+"");
- System.out.println("Titik Potong Dgn Sumbu X1 = "+obj2.rumusx1()+ "dan X2 = " +obj2.rumusx2());
- System.out.println("Titik Potong Dgn Sumbu Y1 = "+obj2.rumusy1()+ "dan Y2 = " +obj2.rumusy2());
- System.out.println("Titik Puncak x= "+obj2.puncakx()+"y= "+obj2.puncaky());
- System.out.println("Sumbu Simetris= "+obj2.sumbusumetri());
- }
- }
- public class Kuadrat {
- double a, b, c;
- double y;
- double d(){
- return (Math.pow(b, 2)-(4*a*c));
- }
- double rumusy1(){
- return a*Math.pow(rumusx1(), 2)+b*rumusx1()+c;
- }
- double rumusy2(){
- return a*Math.pow(rumusx2(), 2)+b*rumusx2()+c;
- }
- double rumusx1() {
- return ((-b + (Math.sqrt(Math.pow(b, 2) - 4 * a * c))) / 2 * a);
- }
- double rumusx2() {
- return ((-b - (Math.sqrt(Math.pow(b, 2) - 4 * a * c))) / 2 * a);
- }
- double puncakx(){
- return -b/(2*a);
- }
- double puncaky(){
- return (d())/-4*a;
- }
- double sumbusumetri(){
- return (-b)/2*a;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement