0% found this document useful (0 votes)
42 views4 pages

Assessment 1

The document describes a program that classifies triangles based on user-input side lengths. It lists assumptions about valid input, provides the algorithm to check the triangle type, includes test cases for different triangle types and invalid inputs, shows the code implementing the algorithm, and provides examples of running the program with different inputs and the resulting outputs.

Uploaded by

Nicole Potter
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views4 pages

Assessment 1

The document describes a program that classifies triangles based on user-input side lengths. It lists assumptions about valid input, provides the algorithm to check the triangle type, includes test cases for different triangle types and invalid inputs, shows the code implementing the algorithm, and provides examples of running the program with different inputs and the resulting outputs.

Uploaded by

Nicole Potter
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

Assumptions
The user wont try to input negative numbers. The user wont try to input a string. The user wont try to input 0. The user will input an integer.

2. Algorithm
scan s1, s2, s3 if (!((s1 + s2) > s3) && ((s1 + s3) > s2) && ((s3 + s2) > s1)) print "Invalid triangle." else if((s1 == s2) && (s1 == s3)) print "Your triangle is an equilateral triangle. else if((s1 == s2) || (s1 == s3) || (s2 == s3)) print Your triangle is an isosceles triangle. else print "Your triangle is a scalene triangle."

3. Test Table
Test # 1 2 3 4 5 6 7 8 Test Description Equilateral Triangle Isosceles Triangle Scalene Triangle Invalid Triangle Zero input Negative number Null input String input Input Expected Outcome Actual Outcome 1,1,1 1,2,2 2,3,4 1,2,3 0,0,0 -1,-1, -1 A Your triangle is an equilateral triangle. Your triangle is an Isosceles triangle. Your triangle is a scalene triangle. Invalid triangle. Invalid triangle. Invalid triangle. Nothing Error Your triangle is an equilateral triangle. Your triangle is an Isosceles triangle. Your triangle is a scalene triangle. Invalid triangle. Invalid triangle. Invalid triangle. Nothing Error Program Success/ Failure Success Success Success Success Success Success Success Success

4. Code
#include <stdio.h> int main(){ int s1, s2, s3; printf("Please enter side one: "); scanf("%d", &s1); printf("Please enter side two: "); scanf("%d", &s2); printf("Please enter side three: "); scanf("%d", &s3); if (!((s1 + s2) > s3) && ((s1 + s3) > s2) && ((s3 + s2) > s1)) { printf("Invalid triangle."); } else { if((s1 == s2) && (s1 == s3)) { printf("Your triangle is an equilateral triangle."); } else if((s1 == s2) || (s1 == s3) || (s2 == s3)) { printf("Your triangle is an isosceles triangle."); } else { printf("Your triangle is a scalene triangle."); } } return(0); }

7. Results of Program Testing


E:\Program Codes>triangles.exe Please enter side one: 1 Please enter side two: 2 Please enter side three: 3 Invalid triangle! E:\Program Codes>triangles.exe Please enter side one: 1 Please enter side two: 1 Please enter side three: 1 Your triangle is an equilateral triangle! E:\Program Codes>triangles.exe Please enter side one: 1 Please enter side two: 2 Please enter side three: 2 Your triangle is an isosceles triangle! E:\Program Codes>triangles.exe Please enter side one: 2 Please enter side two: 3 Please enter side three: 4 Your triangle is a scalene triangle! E:\Program Codes>triangles.exe Please enter side one: 0 Please enter side two: 0 Please enter side three: 0 Invalid triangle! E:\Program Codes>triangles.exe Please enter side one: -1 Please enter side two: -1 Please enter side three: -1 Invalid triangle! E:\Program Codes>triangles.exe Please enter side one: a Please enter side two: Please enter side three: Invalid triangle!

8. Self Assessment

You might also like