Define a class to overload the method perform as follows: ouble perform (doubler, double h)to calculate and return the value of Curved surface area of c)
Advertisements
प्रश्न
Define a class to overload the method perform as follows:
| double perform (double r, double h) | to calculate and return the value of Curved surface area of cone CSA π rl `l = sqrt(r^2 + h^2)` |
| void perform (int r, int c) | Use NESTED FOR LOOP to generate the following format r = 4, c = 5 output - 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 |
| void perform (int m, int n, char ch) | to print the quotient of the division of m and n if ch is Q else print the remainder of the division of m and n if ch is R |
थोडक्यात उत्तर
Advertisements
उत्तर
class Overloading
{
double perform( double r, double h)
{
double l=Math.sqrt(r*r+h*h);
double csa=3.142*r*l;
return csa;
}
void perform(int r, int c)
{
for(int i=1;i<=r;i++)
{
for(int j=1;j<=c;j++)
System.out.print(j+" ");
System.out. println();
}
}
void perform(int m, int n, char ch)
{
if(ch=='Q')
System.out.println("Quotient="+m/n);
else if(ch=='R')
System.out.println("Remainder="+m%n);
else
System.out.println("Invalid operation");
}
}
Output:
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
shaalaa.com
Introduction of Nested Loop
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
