In: Computer Science
Create a project that gets input from the user. ( Name the project main.cpp)
Ask the user for a value for each side of the triangle.
Comment your code throughout.
Include your name in the comments.
Submit the plan-Psuedo code (include Flowchart, IPO Chart) and the desk check with each submission of your code.
Submit the plan as a pdf.
Snips of your output is not a plan.
Not a triangle
Expected Output
Remember to submit each time items below along with your code.
Plan (Psuedo code, Flowchart, IPO Chart)
Desk check
Starter Code:
"Welcome user. Type in the side lengths of your triangle and I
will classify it. "<<endl;
"Enter the length of each side. "<<endl;
"This is not a triangle. All side lengths must be greater than
zero."<<endl;
"This is not a triangle because the sum of the\ntwo smaller side
lengths is not greater than the largest side
length."<<endl;
"Your triangle is ";
"an equilateral triangle because all side lengths are
equal."<<endl;
"a scalene triangle because no side lengths are equal."<<endl;
"an isosceles triangle because only two side lengths are equal."<<endl;
Code:
#include <iostream>
using namespace std;
int main() {
int a,b,c; //to store the value of sides of tringle
cout<<"Welcome user. Type in the side lengths of your
triangle and I will classify it. "<<endl<<"Enter the
length of each side. "<<endl;
cin >> a; //this take input from user
cin >> b;
cin >> c;
if(a<=0||b<=0||c<=0) //check for negative side value
cout<<"This is not a triangle. All side lengths must be
greater than zero."<<endl;
else if(a+b<=c||a+c<=b||b+c<=a)
cout<<"This is not a triangle because the sum of the\ntwo
smaller side lengths is not greater than the largest side
length."<<endl;
else {
cout<<"Your triangle is ";
if(a==b==c)
cout<<"an equilateral triangle because all side lengths are
equal."<<endl;
else if(a==b||b==c||c==a)
cout<<"an isosceles triangle because only two side lengths
are equal."<<endl;
else
cout<<"a scalene triangle because no side lengths are
equal."<<endl;
}
return 0;
}
flow chart