Login|Contact Us
Question and Answer

Programming

Ask a Programming Question, Get an Answer ASAP!

  • Ask A Question
  • Browse Answers
  • Meet The Experts
  • How JustAnswer Works

The sum of the lengths of any two sides of a triangle must

 
Simit's Avatar
  • Answered by:Simit
  • Programming Tutor
  • Positive Feedback: 99.1 %
  • Accepted Answers: 226
Verified Expert
in Programming

Recent Feedback

Positive
Thank you,but this should be easy to find on the website.Not have to go through...
Positive
Knows so much and is patient!
Positive
Love it! Why didn't I ask earlier? I was already going to ship out that RAM to...
Positive
I did the reset as suggested. From the install CD I tried an install. Will not...
Positive
Simit gave thoughtful, knowledgeable and detailed answers to my questions and...
Positive
fast svc. good result
Positive
PERFECT!
Positive
GREAT AND FAST
Positive
answered my question - bought the cord computer works fine now!
Positive
Thanks very much for the help. Dick Turner

Customer Question

The sum of the lengths of any two sides of a triangle must be greater than the length of the third side. For example, the numbers 3, 4, and 5 can form a triangle because 3+4 > 5, 4+5 > 3, and 5+3 > 4. In contrast, the numbers 1, 2, and 5 cannot form a triangle because 1+2 < 5. Thus, if you are given any three integers, you can determine whether they could possibly form a triangle or not by applying this general principle

 

Optional Information:
Computer OS: Windows Vista
Browser: Firefox

Already Tried:
None

Submitted: 1301 days and 9 hours ago.
Category: Programming
Value: $22
Status: CLOSED
Picture
Expert:  Simit replied 1301 days and 9 hours ago.

What language do you need this in?

Customer replied 1301 days and 9 hours ago.

Java

Accepted Answer

Picture
Expert:  Simit replied 1301 days and 8 hours ago.

Here you go. Let me know if you need help with it:


import java.util.Scanner;


class Echo{
   public static void main (String [] args) throws java.io.IOException   {
          Scanner console = new Scanner(System.in);
          Integer s1;
          Integer s2;
          Integer s3;
          System.out.print("Enter the length of the first side of the triangle: ");
          s1 = Integer.parseInt(console.next());
          
          System.out.print("Enter the length of the second side of the triangle: ");
          s2 = Integer.parseInt(console.next());
          
          System.out.print("Enter the length of the third side of the triangle: ");
          s3 = Integer.parseInt(console.next());

          if (s1 + s2 <= s3){
               System.out.print("These 3 integers cannot form a triangle");
          }
          
          else if (s1 + s3 <= s2){
               System.out.print("These 3 integers cannot form a triangle");
          }
          
          else if (s2 + s3 <= s1){
               System.out.print("These 3 integers cannot form a triangle");
          }
          
          else
               System.out.print("These 3 integers would form a triangle");
       
    }
}

Expert TypeProgramming Tutor
Category: Programming
Pos. Feedback: 99.1 %
Accepts: 226
Answered: 9/16/2009

Experience: I have my Bachelor in Computer Engineering. I took many programming classes in college.

Ask this Expert a Question >
Customer replied 1301 days and 8 hours ago.

Programming Assignment 2 i for got the second part and yes i will pay more

The sum of the lengths of any two sides of a triangle must be greater than the length of the third side. For example, the numbers 3, 4, and 5 can form a triangle because 3+4 > 5, 4+5 > 3, and 5+3 > 4. In contrast, the numbers 1, 2, and 5 cannot form a triangle because 1+2 < 5. Thus, if you are given any three integers, you can determine whether they could possibly form a triangle or not by applying this general principle.

Write a JavaScript program that allows a user to input three integers using text boxes in a form. (Hint: You need to use the built-in parseInt function to convert the input strings to integers.) Test the three integers to determine if they can be formed into a triangle using the rule given above. Also test if the resulting triangle would be a right triangle using the Pythagorean theorem, namely that the square of the hypotenuse (the longest side) equals the sum of squares of the other two sides. Display an alert box to inform the user whether their integers can form a triangle or a right triangle (tell them which), or if the integers cannot form a triangle. Continue accepting sets of three integers and testing them until the user decides to quit.

Picture
Expert:  Simit replied 1301 days and 8 hours ago.

So is this an html form?

Customer replied 1301 days and 7 hours ago.

JavaScript

Picture
Expert:  Simit replied 1301 days and 7 hours ago.

So you need a web page that takes the 3 inputs, and javascript which does the calculation, right?

Customer replied 1301 days and 7 hours ago.

yes

Customer replied 1301 days and 7 hours ago.

The firt part of the progarm was good i just need it to out put a triangle whe the answer

is correct.

Accepted Answer

Picture
Expert:  Simit replied 1301 days and 7 hours ago.

Here's the code for the javascript:

<html>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function solvept(form) {
a = parseInt(form.a.value);
b = parseInt(form.b.value);
c = parseInt(form.c.value);

if (a + b <= c){
     alert("These 3 integers cannot form a triangle");
}
          
else if (a + c <= b){
     alert("These 3 integers cannot form a triangle");
}
          
else if (b + c <= a){
     alert("These 3 integers cannot form a triangle");
}
          
else if ((a*a) + (b*b) - (c*c) == 0 || (a*a) + (c*c) - (b*b) == 0) || (b*b) + (c*c) - (a*a) == 0){
     alert("These 3 integers would form a right triangle");
}

else
     alert("These 3 integers would form a triangle, but not a right triangle");
}
// End -->
</script>

<body>

<form>
<center>

<input type=text name=a size=3><br>
<input type=text name=b size=3><br>
<input type=text name=c size=3><br>
<p>
<input type=button value="Solve" onClick="solvept(this.form)">
</form>
</body>
</html>

Expert TypeProgramming Tutor
Category: Programming
Pos. Feedback: 99.1 %
Accepts: 226
Answered: 9/16/2009

Experience: I have my Bachelor in Computer Engineering. I took many programming classes in college.

Ask this Expert a Question >
Picture
Expert:  Simit replied 1301 days and 7 hours ago.

Also, what do you mean you need to output a triangle?
Is this in the first assignment?

Please provide some detail on what that should look like.

Customer replied 1301 days and 6 hours ago.

thank you thats it i have two more programs

here is one more

 

 

Programming Assignment 4

Create an html document that includes a JavaScript program that creates a new constructor function named Automobile in the document head. Include at least five properties in the object definition, such as make, model, color, engine, seats, and so forth. Then assign the values of your car to each of the Automobile properties. Print the properties to the screen. i will pay $20.00 for help on this one

Picture
Expert:  Simit replied 1301 days and 6 hours ago.

I'm sorry. I just don't have much experience with javascript to do anything beyond something similar to the last one. I really don't know how to do this one.

Also, I'm not sure if you forgot, but you never paid for the first program, only the second.

Customer replied 1301 days and 5 hours ago.

yes i did pay for the first one Thanks

 

if you make one just like the last one thats fine html

Customer replied 1299 days and 6 hours ago.

I have 0 Balance in my account i will load it tommorrow

 

and pay you

 

 

But the program dose not output an answer

and you were right the program can be html but have some javascript in the program

saved as an . html

you dont have to sumit the program until i pay tomorrow

 

Write a JavaScript program that allows a user to input three integers using text boxes in a form. (Hint: You need to use the built-in parseInt function to convert the input strings to integers.) Test the three integers to determine if they can be formed into a triangle using the rule given above. Also test if the resulting triangle would be a right triangle using the Pythagorean theorem, namely that the square of the hypotenuse (the longest side) equals the sum of squares of the other two sides. Display an alert box to inform the user whether their integers can form a triangle or a right triangle (tell them which), or if the integers cannot form a triangle. Continue accepting sets of three integers and testing them until the user decides to quit.

 

 

Accepted Answer

Picture
Expert:  Simit replied 1299 days and 6 hours ago.

Sorry about that. It looks like an extra ')' got in there somehow. Here's the revised code:

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function solvepy(form) {
a = parseInt(form.a.value);
b = parseInt(form.b.value);
c = parseInt(form.c.value);

if (a + b <= c){
     alert("These 3 integers cannot form a triangle");
}
          
else if (a + c <= b){
     alert("These 3 integers cannot form a triangle");
}
          
else if (b + c <= a){
     alert("These 3 integers cannot form a triangle");
}
          
else if ((a*a) + (b*b) - (c*c) == 0 || (a*a) + (c*c) - (b*b) == 0 || (b*b) + (c*c) - (a*a) == 0){
     alert("These 3 integers would form a right triangle");
}

else
     alert("These 3 integers would form a triangle, but not a right triangle");
}
// End -->
</script>


<form>
<center>

<input type=text name=a size=3><br>
<input type=text name=b size=3><br>
<input type=text name=c size=3><br>
<p>
<input type=button value="Solve" onClick="solvepy(this.form)">
</form>

Expert TypeProgramming Tutor
Category: Programming
Pos. Feedback: 99.1 %
Accepts: 226
Answered: 9/18/2009

Experience: I have my Bachelor in Computer Engineering. I took many programming classes in college.

Ask this Expert a Question >
Customer replied 1299 days and 2 hours ago.

Thanks it work I will pay you tomorrow

 

Embarassed

 
Tweet

7 Programmers are Online Right Now

Ask Your Question Now
Programming Questions Date Submitted
C ProgrammingDecode LabYour assignment is to write a C 4/9/2013
Reference the following instructions to assist you when completing 4/8/2013
First you will present the pseudo code with all the modules 4/8/2013
NA-112 4/8/2013
The first programming project involves completing a program 4/8/2013
RA-201 4/7/2013
This is my final exam for my c programming class. It is due 4/7/2013
Program Description Your program will display (see the sample 4/6/2013
RA-211 4/3/2013
ra-614 4/2/2013
RSS
Next 10 >
Ask A Programmer
Type Your Programming Question Here...
characters left:

Top Programming Experts

See More Programmers

In The News

Nbc
Washington Post
New York Times
Cnn
Learn More

How It Works

  • Ask an Expert
  • Get a Professional Answer
  • Ask Followup Questions
  • 100% Satisfaction Guarantee
Learn More
close
Find Expert answers related to your question.
Sign up using email
We will never post anything without your permission.
Already have an account? Sign in

Ask a Programmer

Get a Professional Answer. 100% Satisfaction Guaranteed.
226 Programmers are Online Now
Type Your Programming Question Here...
characters left:
Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.
Truste
Contact Us | Terms of Service | Privacy & Security | About Us
© 2003-2013 JustAnswer LLC