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

I have started the program got have gotten stuck on how to proceed. Write a C++

ID: 3755197 • Letter: I

Question

I have started the program got have gotten stuck on how to proceed.

Write a C++ program that will read in three double values as the three possible sides of a triangle. Please keep in mind that not all three values can form a triangle. For the three values to form a triangle, the sum of any given two values must be larger than the third value. If it is a triangle, you need to display the type of triangle. Your program must allow the user to repeat this process as often as the user wishes (use y/n or sentinel technique). Please provide the following functions at the minimum, but feel free to add more functions: • A function to input the three sides and makes sure they are positive (i.e., user must reenter the data if a negative value is entered). o void inputSides(double &s1, double &s2, double &s3) • A function to determine and then returns the type of the triangle (do not print the type of the triangle in this function). Use the following triangle types: o invalid triangle (sum of any two sides is less or equal to third side) o scalene triangle (3 different sides) o isosceles triangle (2 of the three sides are the same) o equilateral triangle (3 sides are the same) o string triangleType(double s1, double s2, double s3) Your main function should have one of the following outlines: call inputSides while value is not sentinel // sentinel loop call triangleType print triangle type call inputSides end while or while response is ‘y’ // y/n loop call inputSides call triangleType print triangle type end while

#include "stdafx.h"

#include <iostream>

void inputSides(double &s1, double &s2, double &s3);

using namespace std;

int main()

{

double s1;

double s2;

double s3;

char answer;

do {

cout << "Enter the value for side 1: " << endl;

cin s1;

cout << "Enter the value for side 2: " << endl;

cin s2;

cout << "Enter the value for side 3 " << endl;

cin s3;

cout << "Would you like to continue this [Y/N] " << endl;

inputSides(s1, s2, s3)

} while (answer == 'Y' || answer == 'y');

if (answer == 'N' || answer == 'n')

{

cout << "This program has ended" << endl;

}

return 0;

}

void inputSides(double &s1, double &s2, double &s3)

{

if (s1 == s2 || s2 == s3 || s1 == s3)

{

cout << "Isosceles triangle " << endl;

}

else if (s1 != s2 || s2 != s3 || s1 != s3)

{

cout << "Invalid triangle" << endl;

}

else (s1 =

}

Explanation / Answer

#include <iostream>

using namespace std;

void inputSides(double &s1, double &s2, double &s3)

{

cout << "Enter the value for side 1: " << endl;

cin>>s1;

while(s1<0)

{

cout<<"Invalid Input"<<endl;

cout<<"Enter again"<<endl;

cin>>s1;

}

cout << "Enter the value for side 2: " << endl;

cin>>s2;

while(s2<0)

{

cout<<"Invalid Input"<<endl;

cout<<"Enter again"<<endl;

cin>>s2;

}

cout << "Enter the value for side 3 " << endl;

cin>>s3;

while(s3<0)

{

cout<<"Invalid Input"<<endl;

cout<<"Enter again"<<endl;

cin>>s3;

}

}

string triangleType(double s1, double s2, double s3)

{

if (s1 + s2 <= s3 || s1 + s3 <= s2 || s2 + s3 <= s1)

return "Invalid Triangle";

else if(s1==s2 && s2==s3)

return "Equilateral Triangle";

else if(s1==s2 || s1==s3 || s2==s3)

return "Isosceles Triangle";

else return "Scalene Triangle";

  

}

int main()

{

double s1;

double s2;

double s3;

char answer;

do {

inputSides(s1, s2, s3);

cout<<triangleType(s1,s2,s3)<<endl;

cout << "Would you like to continue this [Y/N] " << endl;

cin>>answer;

} while (answer == 'Y' || answer == 'y');

if (answer == 'N' || answer == 'n')

{

cout << "This program has ended" << endl;

}

return 0;

}