#include <iostream>
#include <cmath>
#include <iomanip>
#define pi acos(-1);
using namespace std;
class Shape
{
public:
virtual void area() {};
};
class Circle : public Shape
{
private:
double r;
public:
Circle(double rr)
{
r = rr;
}
Circle() {};
virtual void area()
{
double ans = pow(r, 2) * pi;
cout << fixed << setprecision(2) << ans << endl;
}
};
class Square : public Shape
{
private:
double a;
public:
Square() {};
Square(double aa) { a = aa; }
virtual void area()
{
cout << fixed << setprecision(2) << pow(a, 2) << endl;
}
};
class Rectangle : public Shape
{
private :
double n, m;
public:
Rectangle() {};
Rectangle(double nn, double mm) { n = nn, m = mm; }
virtual void area()
{
cout <<fixed << setprecision(2)<< n * m << endl;
}
};
int main()
{
int t;
cin >> t;
while (t--)
{
double r, n, m, a;
cin >> r >> a >> n >> m;
Circle one(r);
Square two(a);
Rectangle three(n, m);
Shape* p;
p = &one;
p->area();
p = &two;
p->area();
p = &three;
p->area();
}
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
using namespace std;
class Vehicle
{
protected:
string no;
public:
virtual void display() = 0;
};
class Car :public Vehicle
{
private:
int number, weight;
public:
Car(string nono, int n, int w)
{
no = nono, number = n, weight = w;
}
virtual void display()
{
cout << number * 8 + weight * 2 << endl;
}
};
class Truck :public Vehicle
{
private:
int number, weight;
public:
Truck(string nono, int w)
{
no = nono, weight = w;
}
virtual void display()
{
cout << weight * 5 << endl;
}
};
class Bus :public Vehicle
{
private:
int number, weight;
public:
Bus(string nono, int n)
{
no = nono, number = n;
}
virtual void display()
{
cout << number * 30 << endl;
}
};
int main()
{
int t;
cin >> t;
while (t--)
{
Vehicle* p;
int n;
string no;
int number, weight;
cin >> n;
if (n == 1)
{
cin >> no >> number >> weight;
Car a(no, number, weight);
p = &a;
cout << no << " ";
p->display();
}
else if (n == 2)
{
cin >>no >> weight;
Truck b(no, weight);
p = &b;
cout << no << " ";
p->display();
}
else
{
cin >>no >> number;
Bus c(no, number);
p = &c;
cout << no << " ";
p->display();
}
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
class Animal
{
protected:
string name ;
string type;
int age;
public:
virtual void speak() = 0;
};
class tiger : public Animal
{
public:
tiger(string ty , string na , int ag)
{
type = ty , name = na , age = ag;
}
virtual void speak()
{
cout << "Hello,I am " << name << ",AOOO."<< endl;
}
};
class dog: public Animal
{
public:
dog(string ty , string na , int ag)
{
type = ty , name = na , age = ag;
}
virtual void speak()
{
cout << "Hello,I am " << name << ",WangWang."<< endl;
}
};
class duck : public Animal
{
public:
duck(string ty , string na , int ag)
{
type = ty , name = na , age = ag;
}
virtual void speak()
{
cout << "Hello,I am " << name << ",GAGA."<< endl;
}
};
class pig : public Animal
{
public:
pig(string ty , string na , int ag)
{
type = ty , name = na , age = ag;
}
virtual void speak()
{
cout << "Hello,I am " << name << ",HENGHENG."<< endl;
}
};
int main()
{
int t;
cin >> t;
while(t--)
{
Animal * p ;
string name , type;
int age;
cin >> type >> name >> age;
if(type == "Tiger")
{
tiger a(type,name, age);
p = &a;
p->speak();
}
else if(type == "Pig")
{
pig b(type,name,age);
p = &b;
p->speak();
}
else if(type == "Duck")
{
duck c(type , name , age);
p = &c;
p->speak();
}
else if(type == "Dog")
{
dog d(type , name , age );
p = & d;
p->speak();
}
else
{
cout << "There is no " << type << " in our Zoo." << endl;
}
}
return 0;
}