Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write MARIE instructions: A controller with a camera examines triangular parts o

ID: 3919956 • Letter: W

Question

Write MARIE instructions:

A controller with a camera examines triangular parts on a conveyor belt of a manufacturing process. Depending on the triangular shape of the part, it instructs the conveyor to route the part to a certain destination.

To simulate its decision process, create a MARIE program that will allow the user to enter three integers, representing the lengths of the sides of a triangle.

The program should display the three input values received and then respond with a conclusion identifying the type of triangle these sides will form.

The MARIE program should give the user the answer (Output) and be ready for the user to enter another set of 3 numbers. So, the program will have to clean up after itself and be ready to start on the next input set from the user.

To form a triangle, the length of any side must be less than the sum of the other two sides. For example, sides of 1, 2, and 4 do not form a triangle. If the three numbers do not form a triangle, inform the user via an error code.

Triangles are classified by the number of sides they have of matching length: 3 is "equilateral"; 2 is "isosceles"; none is "scalene".

The program should gracefully handle any bad data, such as one side with a zero value.

Negative numbers in input are NOT bad data. The camera subsystem can give a negative value depending on the direction of the side of the part. For the routing function, use the positive magnitude of any negative input received.

Halt the program when the user enters three zeros as the input values.

Explanation / Answer

#include<bits/stdc++.h>

using namespace std;

int main()

{

int m1,m2,m3; //intialize the sides of the triangle

last:

{

cout<<"==================================================="<<endl;

cout<<"WELCOME TO MARIE PROGRAM :"<<endl;

cout<<"To continue further enter the sides of the triangle"<<endl;

cout<<"==================================================="<<endl;

cin>>m1>>m2>>m3; //take input from user

if(m1==0 && m2==0 & m3==0) //checks for bad data

{

cout<<"Program halting...."<<endl;   

exit(0); //exits the program

}

else if(m1==0 || m2==0 || m3==0) //checks for bad data

{

cout<<"Bad Data....."<<endl;

}

else

{

if(abs(m1)==abs(m2) && abs(m2)==abs(m3) && abs(m3)==abs(m1)) //checks for equilateral triangle

{

cout<<"It is an equilateral triangle"<<endl;

}

else if(abs(m1)==abs(m2) || abs(m2)==abs(m3) || abs(m3)==abs(m1)) //checks for isosceles triangle

{

if(abs(m1)+abs(m2)>abs(m3) && abs(m2)+abs(m2)>abs(m1) && abs(m1)+abs(m3)>abs(m2))

{

cout<<"It is an isosceles triangle"<<endl;

}

else

{

cout<<"Bad data"<<endl;

}

}

else //scalene triangle

{

if(abs(m1)+abs(m2)>abs(m3) && abs(m2)+abs(m2)>abs(m1) && abs(m1)+abs(m3)>abs(m2))

{

cout<<"It is a scalene triangle"<<endl;

}

else

{

cout<<"Bad data"<<endl;

}

}

}

}goto last; // continues to take the input until the program is halted

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote