+ 1
Hii everyone!! Here is my code which is nt working..plzz give suggestion or remove d error from d program n fix it
This is my code Someone help me plzzzzz https://code.sololearn.com/cNehm5ttt8cq/?ref=app In this code, i want to input any two side which i dont know whether it is height,breadh or hypotenius as like dis it is just an example Enter the height 36 Enter the breadth 46 hyp = ? Using only buffered reader and ternary operaror here i can also take breadth or hyp in place of height I know u can solve my prblm so plzzzzz Arun Tomar Mohammad Nabavi Fata1 Err0r Elmer Martens Gaurav Agrawal @
9 Antworten
+ 7
Harsh Agrawal I would help you, but Java is my worst language. I'm sorry.
+ 4
Harsh Agrawal Maybe I don't really get what you want so I just fix the errors from your code...
import java.io.*;
class abc
{
public static void main(String args[]) throws IOException
{
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the height");
double a= Double.parseDouble(br.readLine());
System.out.println("enter the breadth");
double b= Double.parseDouble(br.readLine());
System.out.println("enter the hyptotenius");
double c= Double.parseDouble(br.readLine());
a= (a+b)>c?a:c;
b= (b+c)>a?b:a;
c= c<(a+b)?c:a;
double hei= Math.sqrt(Math.pow(c,2)-Math.pow(b,2));
double bre= Math.sqrt(Math.pow(c,2)-Math.pow(a,2));
double hyp= Math.sqrt(Math.pow(a,2)+Math.pow(b,2));
System.out.println(hei);
System.out.println(bre);
System.out.println(hyp);
}
}
+ 3
https://code.sololearn.com/c3I0D0b26Fre/?ref=app
Harsh Agrawal
i do it but with the help of scanner class..
you did so many mistakes
like taking same variables so many time..
or
you declaration one variables
so many time..
i.e i did not change your program..
so
you learn from your mistakes
+ 3
thnxxx Elmer Martens
but this is not what i want
but i m happy that u try n give some suggestion about dis code
+ 2
Harsh Agrawal
According to your program..
and your word..
you need find out the third side of right angle triangle.
you only take two input from the user..
now user have a choice..
which side he or she want to find out
wheathe it can be
height
or
breath
or
hypontinus
i not say it can not be done..
but using only ternary operator
make it complex....
Elmer Martens
hope you now understand the questions..
let me know
+ 1
Arun Tomar I just want to use ternary operator so plzzz make it with ternary operator only
plzzzz yrrrrrrr Dont make it with any other as like switch case,if,if else etc
+ 1
Elmer Martens this is nt a program what i want? plzzzz read my question carefully den make it plzzzzz
+ 1
but Arun Tomar i just want to make it wid ternary operator dats why this program became complex n tough but when der is nothing hard to do it does nt make excitment to do dat work
hope u get it so if u hve any trick to do dis den plzzz solve it for me....
thnxxxxx n
thnxxxx in advance