Yahoo Answers is shutting down on 4 May 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

How to make a program display triangle, not a triangle or right triangle?

I'm doing a program for my computer programming class and it's about triangles. We have to input 3 measurements for each angle. If it doesn't add up to 180 then get it to print out "This is not a triangle.". If it adds up to 180 then get it to print out "This is a triangle.". And if it adds up to 180 and one of the angles is 90 then get it to print out "This is a right triangle.". We can only have one statement i.e. it can't say it's a triangle and right triangle.

This is what I have and I know it's wrong. If you could explain what's wrong it would help.

50 input "First angle measurement";a1

60 input "second angle measurement";a2

70 input "Third angle measurement";a3

80 let sum=a1+a2+a3

85 cls

90 if sum<>180 then print "This is not a triangle."

100 if sum=180 then print "This is a triangle."

105 if sum=180 and a1=90 then print "This is a right triangle."

110 if sum=180 and a2=90 then print "This is a right triangle."

115 if sum=180 and a3=90 then print "This is a right triangle."

Update:

This is BASIC language

Update 2:

This may be easier to follow:

90 rem *************

100 rem Control Mod

110 rem *************

120 gosub 1000

130 gosub 2000

150 end

1000 rem ***********

1010 rem Input Mod

1020 rem ************

1030 cls

1040 input "First angle measurement";a1

1050 input "Second angle measurement";a2

1060 input "Third angle measurement";a3

1900 cls

1999 return

2000 rem **************

2010 rem Calc\Test Mod

2020 rem **************

2030 let sum=a1 a2 a3

2040 if sum 180 then print "This is not a triangle."

2050 if sum=180 then print "This is triangle."

2060 if sum=180 and a1=90 then print "This is a right triangle."

2070 if sum=180 and a2=90 then print "This is a right triangle."

2080 if sum-180 and a3=90 then print "This is a right triangle."

2999 return

1 Answer

Relevance
  • Link H
    Lv 6
    8 years ago
    Favourite answer

    Your program can work if it can exit after any print statement, but "This is a right triangle" would need testing before "This is a triangle".

Still have questions? Get answers by asking now.