Example of Class, Object, Constructor, Method, Input From User
import "dart:io";
class Mathematics {
var a,b,c,d,e,f,g,r;
Mathematics(double x, double y) {
a = x;
b = y;
}
// void getData(double x, double y) {
// a = x;
// b = y;
// }
void Circumference() {
double ans = (3.14 * a * a);
print(ans);
}
double Formula() {
c = ((a + b)*(a+b)*(a+b));
return c;
}
double calculate() {
// a^2 - b^2 = (a+b)(a-b);
d = (a + b)*(a - b);
return d;
}
}
void main() {
// Mathematics math = new Mathematics();
print("Please Enter value of r: ");
double i =double.parse(stdin.readLineSync()!);
print("Please Enter value of a: ");
double o = double.parse(stdin.readLineSync()!);
print("Please Enter value of b: ");
double p = double.parse(stdin.readLineSync()!);
// math.getData(i, o);
Mathematics math = new Mathematics(i,o);
math.Circumference();
print(math.Formula());
print(math.calculate());
}
Comments
Post a Comment