Overloaded Function to find area of scalene triangle, area of trapezium and area of rhombus. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

21st Oct 2020, 1:58 PM
Sheetal
Sheetal - avatar
10 Answers
+ 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.
21st Oct 2020, 3:40 PM
QTWizard
+ 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!
21st Oct 2020, 3:00 PM
Sheetal
Sheetal - avatar
+ 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?
21st Oct 2020, 2:46 PM
Sheetal
Sheetal - avatar
+ 1
Can anyone help me out in detecting my mistake or is it a run time error?
21st Oct 2020, 2:48 PM
Sheetal
Sheetal - avatar
+ 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
21st Oct 2020, 3:06 PM
QTWizard
+ 1
QTWizard Why is it only working with 1 and why not with other values like 2,3,so on
21st Oct 2020, 3:37 PM
Sheetal
Sheetal - avatar
+ 1
QTWizard Thanks!! I have understood.
21st Oct 2020, 3:48 PM
Sheetal
Sheetal - avatar
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.
21st Oct 2020, 2:16 PM
QTWizard
0
Sheetal i have just run your code, works fine. Heron's formula is correct. I am not sure what is your specific problem.
21st Oct 2020, 2:56 PM
QTWizard
0
DACK:CHESS , stop advertising or else you are in trouble!
22nd Oct 2020, 2:45 AM
Dino Wun (Use the search bar plz!)
Dino Wun (Use the search bar plz!) - avatar