Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,712 members, 7,955,685 topics. Date: Sunday, 22 September 2024 at 12:43 PM |
Nairaland Forum / Science/Technology / Programming / Please Help With This Java Program. (1484 Views)
Java Program To Solve Quadratic Equation-dealwap / How To Create A Small Gui(graphical User Interface) Using Jframe In Java Program / Import Dll Into Java Program (2) (3) (4)
Please Help With This Java Program. by Emyemyberry(m): 9:15pm On Aug 11, 2014 |
Write a java program that is capable of calculating the length of a triangle using cosine rule hint1:let the lenghts be L1,L2, and L3 hint2L1)^2 = (L2)^2 (L3)^2 - 2(L2L3cosL) thanks in advance,awaiting ur solutions. |
Re: Please Help With This Java Program. by fattbabakay(m): 10:04pm On Aug 11, 2014 |
Guys just dey view dey commot...smh |
Re: Please Help With This Java Program. by mj(m): 10:03am On Aug 12, 2014 |
Emyemyberry: Write a java program that is capable of calculating the length of a triangle using cosine rule pls provide the fomular in plain text?? |
Re: Please Help With This Java Program. by Emyemyberry(m): 10:10am On Aug 12, 2014 |
mj:here
|
Re: Please Help With This Java Program. by Olyboy16(m): 8:08pm On Aug 12, 2014 |
Emyemyberry: hereAhem, the guy said in plain text! Not picture! I'm wilin to help |
Re: Please Help With This Java Program. by Emyemyberry(m): 8:17pm On Aug 12, 2014 |
Olyboy16:sori,bt i dnt undstnd wot you mean by plain inbtw,isn't my 1st post in plain?,pls xplahn. |
Re: Please Help With This Java Program. by Emyemyberry(m): 8:17pm On Aug 12, 2014 |
Olyboy16:sori,bt i dnt undstnd wot you mean by plain text inbtw,isn't my 1st post in plain?,pls xplahn. |
Re: Please Help With This Java Program. by Olyboy16(m): 8:23pm On Aug 12, 2014 |
Emyemyberry: sori,bt i dnt undstnd wot you mean by plain text inbtw,isn't my 1st post in plain?,pls xplahn.Owkay, write the formular out in ur post..u get dat? |
Re: Please Help With This Java Program. by Olyboy16(m): 8:47pm On Aug 12, 2014 |
Oh, the cosine rule. Owkay.
you'r welcome |
Re: Please Help With This Java Program. by Intellab(m): 8:48pm On Aug 12, 2014 |
//Try this import java.util.Scanner; public class CosineTriangle { public static void main (string[]args) { //author Speed23 //Program to calculate length of triangle using cosine rule /* Not Tested. But should work */ Scanner user_input = new Scanner(System.in); float l1,l2,l3,ans; System.out.print("Enter your l1" l1=user_input.next()f; System.out.print("Enter your l2" l2=user_input.next()f; System.out.print("Enter your l3" l3=user_input.next()f; // Applying formular ans= ((l1^2+l2^2-l3^2)/2*l1*l2) - cos(l1) System.out.println("Answer is = "+ans); } } 1 Like |
Re: Please Help With This Java Program. by sealteam66(m): 10:33pm On Aug 12, 2014 |
The first problem I had with your programme was how to calculate the cosine of a an angle in degree which I have solved Math.cos((Math. PI)/angle) Now before I speak about the programme, let agree that cosine rule is C sq = A sq + B sq +2ABcosangle where C is certainly the hypotenuse A or B opposite or adjacent respectively and angle is the angle between the adjacent and opposite, i.e. facing the hypotenuse If you write a programme that calculates the lenght of a side using the formulae you will have a logical error because the programme wil be looking for hypotenuse always, when you could actually be looking for opposite or adjacent! For the programme to work, The programme would have to ask you which of the sides is being looked for either hypotenuse, adjacent or opposite after which it accepts value, computes and displays the result What I've done is the algorithm design, which is the first step in programming After this you commence coding Call me on 08090642393, let me know that is in it for me |
Re: Please Help With This Java Program. by Olyboy16(m): 12:55am On Aug 13, 2014 |
sealteam66: The first problem I had with your programme was how to calculate the cosine of a an angle in degree which I have solvedwat the?? Call u? For few lines of codes?? This is cwious!! Wish i had my computer here. You dont need to know wich part of d triangle to solve! Its cosine rule for God's sake. It was designed to solve sides of an isoceles triangle!! Na wa 4 u o. Nd u dey form boss |
Re: Please Help With This Java Program. by LordRahl001: 4:38pm On Aug 13, 2014 |
This should work perfectly. import java.util.Scanner; public class CosineAssignment { //L1^2=L2^2+L32-2L2L3cosL public static void main(String[] args) { double l1, l2, angle; Scanner in=new Scanner(System.in); System.out.println("Supply The First Length:" l1=in.nextDouble(); System.out.println("Supply The Second Length:" l2=in.nextDouble(); System.out.println("Please Supply The Angle" angle=in.nextDouble(); double l1sq=squares(l1); //squaring The First Length double l2sq=squares(l2); //squaring The Second Length double cos_angle=Math.cos(Math.toRadians(angle)); //getting the cosine of the angle double cs=l1sq+l2sq; double csv=(2*l1*l2*cos_angle); double ans=Math.sqrt(cs-csv); System.out.println("The Length is: "+ans); } private static double squares(double fig){ return fig*fig; //this is just to square the lengths. } } Hope i am not late?? |
Re: Please Help With This Java Program. by LordRahl001: 4:40pm On Aug 13, 2014 |
Olyboy16: Oh, the cosine rule. Owkay.Your cosine would return a wrong value. |
Re: Please Help With This Java Program. by LordRahl001: 4:47pm On Aug 13, 2014 |
sealteam66: The first problem I had with your programme was how to calculate the cosine of a an angle in degree which I have solvedits definitely not about hypothenuse its just about you finding the length facing the angle. basically, its represented as: The lengths a,b and c The angles are A,B and C so 2 sides and an angle are give and u are asked to get the length of the last side. most times the unknown side always have its angle known or computed somehow so the Formula actually is: to find length c c=SQRT(a*2b*2+2abcosC) so thats the right formula. The Cases were misleading tho!! |
Re: Please Help With This Java Program. by Olyboy16(m): 7:35pm On Aug 13, 2014 |
LordRahl001:No it wont, check my codes very well. |
Re: Please Help With This Java Program. by LordRahl001: 7:50pm On Aug 13, 2014 |
Olyboy16:I figured u'd say that but in java, Math.cos() expects d variable in radians but u r supply diff nomenclature here!! Try it out and c d output. Coz 60 shud give u 0.5 but Math.cos() will give u another thing entirely. Cheers, |
Re: Please Help With This Java Program. by Olyboy16(m): 7:59pm On Aug 13, 2014 |
LordRahl001: I figured u'd say that but in java, Math.cos() expects d variable in radians but u r supply diff nomenclature here!! Try it out and c d output. Coz 60 shud give u 0.5 but Math.cos() will give u another thing entirely. Cheers,Thanks. I'm much of a consumer based softwares guy in java..thanks 1 Like |
Re: Please Help With This Java Program. by LordRahl001: 8:22pm On Aug 13, 2014 |
Olyboy16:you are welcome sir!!! |
Re: Please Help With This Java Program. by Emyemyberry(m): 12:23am On Aug 14, 2014 |
LordRahl001: This should work perfectly.omg,thanks alot boss,more grace to you |
Re: Please Help With This Java Program. by Emyemyberry(m): 12:28am On Aug 14, 2014 |
Special thanks to olyboy16 , intellab , lordRahl001 1 Like |
Re: Please Help With This Java Program. by LordRahl001: 9:58am On Aug 14, 2014 |
Emyemyberry: omg,thanks alot boss,more grace to youu are welcome boss!!! God bless you too. 1 Like |
Re: Please Help With This Java Program. by sealteam66(m): 10:28pm On Aug 16, 2014 |
LordRahl001: Emyemyberry I acted like a dick head, i believe you have resolved the issue, If you still want the program, I can write it for you, absolutely FREE! |
Re: Please Help With This Java Program. by Emyemyberry(m): 8:07am On Aug 17, 2014 |
sealteam66:thanks man for the concern,hope you can do smthing wt the "if statement" for the question |
Re: Please Help With This Java Program. by fattbabakay(m): 9:58am On Aug 17, 2014 |
sealteam66: The first problem I had with your programme was how to calculate the cosine of a an angle in degree which I have solvedHypotenuse?? Na right angled triangle?? |
Re: Please Help With This Java Program. by sealteam66(m): 1:05pm On Aug 17, 2014 |
Emyemyberry: thanks man for the concern,hope you can do smthing wt the "if statement" for the question Elaborate on the if statement |
(1) (Reply)
PDF, DOC, DOCX To Text Converter Software / Please Programmars Help Me Out With This C# Program! I Have Test Tommorrow!!!!! / Buy A Top Level .com Domain Name, Ssl Support And Host For N5,000 (per Year)
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 44 |