0
What is wrong in my code?
// Areas Of Different Shapes // // Type: 1 for area of rectangle // // Type: 2 for area of circle // // Type: 3 for area of triangle // import java.util.Scanner; class AreasOfShapes { public static void main(String[] args) Scanner s= new Scanner(System.in); { int a,l,b,h,r ; a = s.nextInt(); if(a== 1) { System.out.println("Area Of Rectangle"); System.out.println("Enter length of Rectangle :"); l= s.nextInt(); System.out.println("Enter Breath of Rectangle :"); b= s.nextInt(); area= l*b; System.out.println("Area Of Rectangle Is :"+ area);} else{System.out.println("Welcome"); } } }
6 Answers
+ 2
No it doesn't work
+ 1
here it is i have corrected it for you. go through it.
// area of rectangle //
import java.util.Scanner;
class AreasOfShapes
{
public static void main(String[] args){
Scanner s= new Scanner(System.in);
double l,b;
l=s.nextDouble();
b=s.nextDouble();
if(l>0&&b>0)
{
System.out.println("Area Of Rectangle");
System.out.println("Enter length of Rectangle :"+l);
System.out.println("Enter Breath of Rectangle :"+b);
double area= l*b;
System.out.println("Area Of Rectangle Is :"+area);}
else{System.out.println("enter valid number");
}
}
}
0
Error is in "public static void main(String[] args)" but I am unable to identify error
0
I think u should put{ below psvm
0
No Aakash it is wrong
0
has no wrong just write the println () ; to print message for user after the scanner statement.