Computer Science, asked by Uzma2002, 1 year ago

write it in scanner plz
fast

Attachments:

Answers

Answered by AbhinavKumarSri
0

import java.util.*;

class Pr{

void main( ){

System.out.println("Enter c to find the area of a circle, S for square and r for rectangle");

Scanner sc=new Scanner(System.in);

char c=sc.next( );

double d;

switch(c){

case 'c': System.out.println("Enter radius");

            double r=sc.nextDouble( );

             d=Math.PI*r*r;

             break;

case 'S': System.out.println("Enter side");

             double s= sc.nextDouble( );

             d=s*s;

             break;

case 'r': System.out.println("Enter length and breadth");

             double l=sc.nextDouble( );

             double b= sc.nextDouble( );

             d=l*b;

             break;

default: System.out.println("Invalid choice");

}

System.out.println("The required area "+d);

}

}


Thank You:)

Similar questions