I want to found more of area for (circle, square ..etc )

I'm using ( switch method).

I read ( radius ,length ,width ,base and height ).

but when I enter Area of square . it want enter
( radius ,length ,width ,base and height )
I mean all thing ..

my question : how can I make my program order enter the required data ?
example , order for triangle ( base and height ) just !

You aren't making any sense

Hi..

I could understand you. You want your program to determine what are all the inputs required by the option and correspondingly it should ask new inputs from user.

eg for circle ---> input jus radius

for rectangle ----> input length and breadth

Am i rite ??????? . Well..... If so.... please see the following code

import java.io.*; 

class are{
  public static void main(String[] args) {
      try{
        BufferedReader object = new BufferedReader(
        new InputStreamReader(System.in));
        System.out.println("Please enter the option you desire");
        System.out.println(" 1. Area of circle ");
         System.out.println("2. Area of Square ");
          System.out.println("3. Area of reactangle ");
           System.out.println("4. Area of triangle ");

        int a= Integer.parseInt(object.readLine());
   
        switch(a)
       {
        case 1 :
           System.out.println("Enter the radius ");
            int r = Integer.parseInt(object.readLine());
            float area = 3.14 * r * r;
            System.out.println("The area of circle is "+area);
            break;
        case 2 :
           System.out.println("Enter the side ");
            int s = Integer.parseInt(object.readLine());
            float areas =  s * s;
            System.out.println("The area of circle is "+areas);
            break;
     :
     :  
   
    }
    catch (Exception e){
      System.out.println("Array out of bounds exaception");
    }
  }
}

So like the above code, code your program to ask input from the user depending upon the value chosen

Am i CLEAR??????

--
rigidboss

^

thank you (F)

yes , you are cleaning

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.