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

**Please write a C++ program **I\'d appreciate it if you could take a screenshot

ID: 3783956 • Letter: #

Question

**Please write a C++ program

**I'd appreciate it if you could take a screenshot/picture and put it up

Thanks

2. 50 Peintsl Write a program that calculates the solution/s ofa quadratic equation. The program should prompt the user for values a, b, and c can prints the solution to the screen. Write a unit conversion program using the conversion factors of the table shown below. Your program should ask the user from which unit he/she want to convert (o al z, lb, in, ft, mi) and which unit he/she want to convert to (ml, 1, g, kg English Metric 29.586 milliliter gallon 3.785 liter 28.3495 grams ounce (OZ und 453.6 grams 254 centimeter inch foot 30.5 centimeter 1.609 kilometer i mile Reject any incompatible conversions (such as gal kin

Explanation / Answer

C++ Program to Calculate Solutions to Quadratic Equations:

#include<bits/stdc++.h>
using namespace std;
int main() {
float a, b, c, x1, x2, D, real, imaginary;
cout << "Enter values of a, b and c: ";
cin >> a >> b >> c;
D = b*b - 4*a*c;
  
if (D >= 0) {
x1 = (-b + sqrt(D)) / (2*a);
x2 = (-b - sqrt(D)) / (2*a);
cout<<"Solutions are: "<<x1<<" & "<<x2<<endl;
}
else {
real = -b/(2*a);
imaginary =sqrt(-D)/(2*a);
cout << "Solutions are " << real << "+" << imaginary << "i" <<" & "<< real << "-" <<imaginary << "i" << endl;
}
return 0;
}

C++ Program for Unit Conversion:

#include<bits/stdc++.h>
using namespace std;
int main() {
   float mag;

   cout<<"Enter the magnitude: ";
   cin>>mag;
cout<<"Enter which unit you want to convert{ou,gal,oz,lb,in}: ";
char s[5];
cin>>s;
cout<<"Enter which unit you want to convert to{ml,l,g,kg,mm,cm,m,km}: ";
char r[5];
cin>>r;
if(strcmp(s,"ou")==0)
{
   if(strcmp(r,"ml")==0)
   {
       cout<<mag<<" Ounce = "<<29.586*mag<<" milliliter "<<endl;
       }
       else if(strcmp(r,"l")==0)
       {
           cout<<mag<<" Ounce = "<<(29.586*mag)/1000.0<<" liter "<<endl;
       }
       else
       {
           cout<<"Invalid Conversion"<<endl;
       }
   }
else if(strcmp(s,"gal")==0)
{
       if(strcmp(r,"ml")==0)
   {
       cout<<mag<<" galoon = "<<3.785*mag*1000<<" milliliter "<<endl;
       }
       else if(strcmp(r,"l")==0)
       {
           cout<<mag<<" galoon = "<<(3.785*mag)<<" liter "<<endl;
       }
       else
       {
           cout<<"Invalid Conversion"<<endl;
       }
   }
   else if(strcmp(s,"lb")==0)
   {
           if(strcmp(r,"g")==0)
   {
       cout<<mag<<" Pound = "<<453.6*mag<<" grams"<<endl;
       }
       else if(strcmp(r,"kg")==0)
       {
           cout<<mag<<" Pound = "<<(453.6*mag)/1000.0<<" Kilogram "<<endl;
       }
       else
       {
           cout<<"Invalid Conversion"<<endl;
       }
   }
   else if(strcmp(s,"oz")==0)
   {
           if(strcmp(r,"g")==0)
   {
       cout<<mag<<" ounce = "<<28.3495*mag<<" grams"<<endl;
       }
       else if(strcmp(r,"kg")==0)
       {
           cout<<mag<<" ounce = "<<(28.3495*mag)/1000.0<<" Kilogram "<<endl;
       }
       else
       {
           cout<<"Invalid Conversion"<<endl;
       }
   }
   else if(strcmp(s,"in")==0)
   {
           if(strcmp(r,"cm")==0)
   {
       cout<<mag<<" inch = "<<2.54*mag<<" centimeters"<<endl;
       }
       else if(strcmp(r,"m")==0)
       {
           cout<<mag<<" inch = "<<(2.54*mag)/100.0<<" neter "<<endl;
       }
       else if(strcmp(r,"km")==0)
       {
           cout<<mag<<" inch ="<<(2.54*mag)/10000.0<<" kilometer"<<endl;
       }
       else if(strcmp(r,"mm")==0)
       {
           cout<<mag<<" inch = "<<(2.54*mag)*10<<" millimeter "<<endl;
       }
       else
       {
           cout<<"Invalid Conversion"<<endl;
       }
   }
  
   else if(strcmp(s,"ft")==0)
   {
           if(strcmp(r,"cm")==0)
   {
       cout<<mag<<" foot = "<<30.5*mag<<" centimeters"<<endl;
       }
       else if(strcmp(r,"m")==0)
       {
           cout<<mag<<" foot = "<<(30.5*mag)/100.0<<" meter "<<endl;
       }
       else if(strcmp(r,"km")==0)
       {
           cout<<mag<<" foot ="<<(30.5*mag)/100000.0<<" kilometer"<<endl;
       }
       else if(strcmp(r,"cm")==0)
   {
       cout<<mag<<" foot = "<<30.5*mag*10<<" millimeters"<<endl;
       }
       else
       {
           cout<<"Invalid Conversion"<<endl;
       }
   }
  
   else if(strcmp(s,"mi")==0)
   {
           if(strcmp(r,"cm")==0)
   {
       cout<<mag<<" mile = "<<1.609*mag*100000.0<<" centimeters"<<endl;
       }
       else if(strcmp(r,"m")==0)
       {
           cout<<mag<<" mile = "<<(1.609*mag)*1000.0<<" meter "<<endl;
       }
       else if(strcmp(r,"km")==0)
       {
           cout<<mag<<" mile ="<<(1.609*mag)<<" kilometer"<<endl;
       }
       else if(strcmp(r,"cm")==0)
   {
       cout<<mag<<" mile = "<<1.609*mag*1000000.0<<" millimeters"<<endl;
       }
       else
       {
           cout<<"Invalid Conversion"<<endl;
       }
   }
   else
   {
       cout<<"Invalid Input"<<endl;
   }
   return 0;
}