Problem: (60 points) Write a program in C++ to calculate the hypotenuse of a rig
ID: 3596079 • Letter: P
Question
Problem: (60 points) Write a program in C++ to calculate the hypotenuse of a right triangle or to solve a quadratic equation. B) If the coefficient e entered is even: (20 points) Make the program calculate the hypothenuse e (with three significant digits) of the triangle below using the following formula: C) If the coefficient e entered is odd: (30 points) 1) Display the following quadratics equation. 2) Modify the code to calculate the discriminant D using the following formula 3) For a non-zero, discuss the roots of the quadratic equation as follows: ax2+bx+c=0 D-b2-4ac a) D =0; the equation has a double solution. X1 =X2=-b/2a D> 0; the equation has two different solutions X1 and X2. X1 (-b-sqrt (D)/2a X2 = (-b+sqrt (D)/2a IfDExplanation / Answer
#include <iostream>
#include<math.h>
using namespace std;
int main() {
int a,b,e,D,x1,c,x2;
cin>>a>>b>>e;
if(e%2==0)
{
c=sqrt((a*a)+(b*b));
cout<<"hypothesis"<<c;
}else
{
cout<<"ax2+bx+c"<<endl;
D=b*b-4*a*e;
if(D==0)
{
x1=x2=-b/(2*a); cout<<"x1"<<x1<<endl<<"x2"<<x2;
}else if(D>0)
{
x1=(-b-sqrt(D))/(2*a);
x2=(-b+sqrt(D))/(2*a);
cout<<"x1"<<x1<<endl<<"x2"<<x2;
}else
{
cout<<"Equation has no real solution";
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.