• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

need homework help!!!!

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I'm studying but just not computer genius In a bveginner Java course, I'm already stuck I have to do a program asking user for 3 numbers and then program decides if 3 numbers can form a triangle The hint prof gives is that rule that sum 2 sides have to be greater than third in any triangle *Well, I didnt write the assignment) I know it if...else..?? HELP!! Thanks PS I use java 1.1.8 and can write and run simple applets and applications fine
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If any of the numbers are bigger than half the length of all the sides added together then a triangle cannot be formed.
sides 4,6,8 4+6+8=18 18/2=9 nothing is bigger then 9 so triangle is possible
int temp = (num1 + num2 + num3)/2;
if(temp > num1 && temp > num2 && temp > num3)
  System.out.println("Triangle can be formed");
 
reply
    Bookmark Topic Watch Topic
  • New Topic