YOUR_GRADER_BADGE looks like this: https://kntu-grader.herokuapp.com/minimal?repo=<REPO_NAME>&id=<YOUR_STUDENT_ID>
Design a class named QuadraticEquation for a quadratic equation
ax^2 + bx + c = 0
The class contains:
-
Private data fields a, b, and c that represent three coefficients.
-
A constructor with three parameter to initialize a, b, and c.
-
Three getter methods for a, b, and c.
-
Do not create any setter method
-
A method named
getDiscriminant()
that returns the discriminant, which is b^2-4ac -
The methods named
getRoot1()
andgetRoot2()
for returning two roots of the equation
سوال فوق را با رعایت سطوح دسترسی پیاده سازی کنید:
package ir.ac.kntu;
public class QuadraticEquation{
//your logic, fields and constructor is here
//a,b,c data type is double, thus the return type of methods are double
//all methods should be public: getRoot1,getRoot2,getA,...
}
انجام دادن اینکار الزامی نیست و به هر مدلی که دوست دارید توابع کلاس خود را تست کنید و شی بسازید
package ir.ac.kntu;
public class TestQuadraticEquation{
public static void main(String[] args){
//read the parameters from user
//new QuadraticEquadion(paramters,....)
}
}
دقت کنید که فقط یک سازنده تعریف کنید
دقت کنید که در صورت عدم رعایت موارد کد تمییز تکلیف شما تا زمانی که این اشکالات را رفع نکنید قبول نمی شود.