+ 5
Overloaded Function to find area of scalene triangle, area of trapezium and area of rhombus.
I can not get the output area of triangle although after entering the correct value of its three sides as input. The program also doesn't have an error and the formula is also correct but still it is not giving the desired area of triangle as output. Please someone help me with this!! Here is my code. https://code.sololearn.com/cLpTmgEcVTrq/?ref=app
10 odpowiedzi
+ 2
Sheetal if you enter:
1
2
3
Then the area of the triangle will be 0 because s = 3 and s - 3 = 0, enter something in such way the difference between s and other numbers does not equal to zero.
+ 2
QTWizard Is it giving the area of triangle according to the values of sides entered as input? When i had ran the code it is giving both the area of trapezium and rhombus correctly but in the case of area of triangle it is giving output as "Area of triangle=0.0". I dont understand why? Thats what i am asking!
+ 1
QTWizard Overloading means only that same function name with different arguments.
I am asking that why is it not working provided that the code is correct?
+ 1
Can anyone help me out in detecting my mistake or is it a run time error?
+ 1
Enter each number on a separate line like:
1
1
1
1
1
1
1
1
Then press the submit button, it should output something like
0.433..
2.0
1.0
+ 1
QTWizard Why is it only working with 1 and why not with other values like 2,3,so on
+ 1
QTWizard Thanks!!
I have understood.
0
I am not an expert in java, but i think overloading works when changing the number of arguments passed to the function and not the data type of the arguments. I think so but i am not sure.
0
Sheetal i have just run your code, works fine. Heron's formula is correct. I am not sure what is your specific problem.
0
DACK:CHESS , stop advertising or else you are in trouble!