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
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
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 =
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started