Question

1.- i need help with my code because it appears me "main.cpp:77:7: error: expected unqualified-id before...

1.- i need help with my code because it appears me

"main.cpp:77:7: error: expected unqualified-id before ‘else’
       else (s ==  't' || s == 'T' || s == '3')
       ^~~~"

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
double l1, l2, bl, h, d, l, p, a, h1, h2, el, ia,sb,sh,P,A,oa,pc ;
double ap,pp,shp,cl,bsp,iap,blp,elp,o;
char s;
double const pi = 3.14159265;

cout <<setfill('*')<<setw(36)<<'*'<<endl;
cout <<setw(1)<<'*'<<" Rebel Alliance Computation Support "<<endl;
cout <<setw(1)<<'*'<<" Star area calculator "<<endl;
cout <<setfill('*')<<setw(36)<<'*'<<endl;
cout <<endl;
  
cout<< "(d/D/2) - Double Star Polygon " <<endl;
cout<< "(t/T/3) - Three Star Polygon " <<endl;
cout<< "(p/P) - Polygram Polygon " <<endl;
cout<< "(q/Q) - Quit "<< endl;
cout<<endl;
  
cout<<"Your selection"<<endl;
cin>>s;
cout<<endl;
  
if (s == 'd' || s == 'D' || s == '2')
{
cout<< "Double Star Polygon Calculator" <<endl;
cout<< setfill('-')<<setw(30)<<'-'<<endl;
cout<< endl;
}
cout<<" Length Long Valid range [1.00 < Length long < 236.00] "<<endl;
cout<<" Length Long: "<<endl;
cin>> l1;
cout<< endl;
  
cout<<" Length Short Valid range [1.00 < Length short < 118.00]"<<endl;
cout<<" Length short: "<<endl;
cin>> l2;
cout<< endl;
  
cout<<" Base Length Valid range [1.00 < Base short < 29.50] "<<endl;
cout<<" Base length: "<<endl;
cin>> bl;
cout<<setfill('-')<<setw(30)<<'-'<<endl;
  
if (l1 < 1.00 || l1 > 236.00|| l2 < 1.00 || l2 > 118.00 || bl < 1.00 || bl > 29.50)
{
cout<<"Invalid Numbers"<<endl;
}
  
else
{
cout<<" Calculations for a Double Star Polygon "<<endl;
cout<<" Base Length: " << bl <<endl;
cout<<" Length Long: " << l1 <<endl;
cout<<" Length Short:" << l2 <<endl;
cout<< setfill('-')<<setw(30)<<'-'<<endl;
cout<< endl;
  
h1 = sqrt(pow(l1, 2.00) - pow(bl, 2.0) / 4.00);
h2 = sqrt((pow(l2, 2.00)) - (pow(bl, 2.0) / 4.00));
d = 2.00 * h1 + bl * (1.00 + sqrt(2.00));
p = 8.00 * (l2 + l1);
a = 2.00 * bl * (bl * (1.00 + sqrt(2.00)) + (h1 + h2));
  
cout<<" Height Long: "<< h1 << endl;
cout<<" Height Short:"<< h2 << endl;
cout<<" Diameter : " << d << endl;
cout<<" Perimeter: " << p << endl;
cout<<" Area: " << a << endl;
}
}
else (s == 't' || s == 'T' || s == '3')
{
cout<<" Threestar Polygon Calculator "<<endl;
cout<<setfill('-')<<setw(30)<<'-'<<endl;
cout<< endl;
  
cout<<" Edge Length Valid range [1.00 < edge length < 132.00]"<< endl;
cout<<" Edge Length: ";
cin>> el;
cout<< endl;
  
cout<<" Inner Angle (degrees) Valid range [0.00 < edge legnth < 60.00]"<< endl;
cout<<" Inner angle (degrees): ";
cin>> ia;
cout<< endl;
cout<<setfill('-')<<setw(30)<<'-'<<endl;
  
if (el < 1.00 || el > 132.00 || ia < 0.00 || ia > 60.00)
{
cout<<" Invalid number "<<endl;
}
  
else
{
cout<<" Calculations for a Threestar Polygon "<<endl;
cout<<" Edge Length: " << el <<endl;
cout<<" Outer angle: " << 120.00 + ia <<endl;
cout<<" Inner angle: " << ia <<endl;
cout<<setfill('-')<<setw(30)<<'-'<<endl;
  
sb = sqrt((2.00 * pow(el, 2.00)) * (1.00 - cos(ia * (pi / 180.00))));
sh = sqrt((4.00 * pow(el, 2.00) - pow(sb, 2.00)) / 4.00);
cl = sqrt(2.00 * pow(el, 2.00) * (1.00 - cos ((120.00+ia) * (pi / 180.00))));
h = (sqrt(3.00) / (2) * cl);
P = 6.00 * el;
A = (3.00 / 2.00) * sh * sb + (sqrt(3.00) / 4.00) * pow(sb, 2.00);
  
cout<< "Spike base: " << sb <<endl;
cout<< "Spike height: " << sh <<endl;
cout<< "Chord length: " << cl <<endl;
cout<< "Height: " << h <<endl;
cout<< "Perimeter: " << P <<endl;
cout<< "Area: " << A <<endl;
}
  
}
else if (s == 'p' || s == 'P'){

cout<<"Polygram Calculator"<<endl;
cout<<setfill('-')<<setw(30)<<'-'<<endl;
cout<< endl;

cout<<" Point Count Valid range [3.00 < point count < 100.00]"<< endl;
cout<<" Point count: ";
cin>> pc;
cout<< endl;
  
cout<<" Edge Length Valid range [1.00 < edge length < 132.00]"<<endl;
cout<<" Edge Length: ";
cin>> elp;
cout<< endl;
  
cout<<" Outer Angle Valid range [0.00 < outer angle < 60.00]"<<endl;
cout<<" Outer angle: ";
cin>> oa;
cout<< endl;
cout<<setfill('-')<<setw(30)<<'-'<<endl;
  
if (pc < 3.00 || pc > 100.00 || elp < 1.00 || elp > 132.00 || oa < 1.00 || bl > 60.00)
{
cout<<" Error - invalid entry "<<endl;
cout<endl;
}

else
{
cout<< "Calculations for Polygram" <<endl;
cout<< "Point count: " << pc <<endl;
cout<< "Edge Length: " << elp <<endl;
cout<< "Outer angle: " << oa <<endl;
cout<<setfill('-')<<setw(30)<<'-'<<endl;
  
iap = oa - 360.00 / pc;
blp = sqrt(2.00 * pow(elp, 2.00) * (1.00 - cos(iap * (pi / 180.00))));
shp = sqrt(((4 * pow(elp, 2.00)) - pow(bsp, 2.00)) / 4.00);
pp = 2 * pc * elp;
ap = (pc * pow(bsp, 2.00)) / (4 * tan(pi/pc)) + (pc * shp*(bsp/2));
  
cout<<" Inner angle: "<< iap <<endl;
cout<<" Base length: "<< blp <<endl;
cout<<" Chord length:"<<endl;
cout<<" Spike Hieght:"<< shp <<endl;
cout<<" Perimeter: " << pp <<endl;
cout<<" Area: " << ap <<endl;
  
}
}
else
{
cout<<"Error - invalid entry"<<endl;
cout<<endl;
}
  
cout <<" Thank you for using Rebel Alliance Computational Support "<<endl;
cout <<" May the Force be with you ! "<<endl;
cout <<" * "<<endl;
cout <<" * *** * "<<endl;
cout <<" * * * * * "<<endl;
cout <<" * ** * "<<endl;
cout <<" ** * ** "<<endl;
cout <<" *** *** *** "<<endl;
cout <<" **** *** **** "<<endl;
cout <<" ***** *** ****** "<<endl;
cout <<" ********************** "<<endl;
cout <<" ******************** "<<endl;
cout <<" ****************** "<<endl;
cout <<" ************** "<<endl;
cout<<endl;
  


return 0;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
   double l1, l2, bl, h, d, l, p, a, h1, h2, el, ia,sb,sh,P,A,oa,pc ;
   double ap,pp,shp,cl,bsp,iap,blp,elp,o;
   char s;
   double const pi = 3.14159265;
  
   cout <<setfill('*')<<setw(36)<<'*'<<endl;
   cout <<setw(1)<<'*'<<" Rebel Alliance Computation Support "<<endl;
   cout <<setw(1)<<'*'<<" Star area calculator "<<endl;
   cout <<setfill('*')<<setw(36)<<'*'<<endl;
   cout <<endl;
  
   cout<< "(d/D/2) - Double Star Polygon " <<endl;
   cout<< "(t/T/3) - Three Star Polygon " <<endl;
   cout<< "(p/P) - Polygram Polygon " <<endl;
   cout<< "(q/Q) - Quit "<< endl;
   cout<<endl;
  
   cout<<"Your selection"<<endl;
   cin>>s;
   cout<<endl;
  
   if (s == 'd' || s == 'D' || s == '2')
   {
       cout<< "Double Star Polygon Calculator" <<endl;
       cout<< setfill('-')<<setw(30)<<'-'<<endl;
       cout<< endl;
       cout<<" Length Long Valid range [1.00 < Length long < 236.00] "<<endl;
       cout<<" Length Long: "<<endl;
       cin>> l1;
       cout<< endl;
      
       cout<<" Length Short Valid range [1.00 < Length short < 118.00]"<<endl;
       cout<<" Length short: "<<endl;
       cin>> l2;
       cout<< endl;
      
       cout<<" Base Length Valid range [1.00 < Base short < 29.50] "<<endl;
       cout<<" Base length: "<<endl;
       cin>> bl;
       cout<<setfill('-')<<setw(30)<<'-'<<endl;

       if (l1 < 1.00 || l1 > 236.00|| l2 < 1.00 || l2 > 118.00 || bl < 1.00 || bl > 29.50)
       {
           cout<<"Invalid Numbers"<<endl;
       }      
       else
       {
           cout<<" Calculations for a Double Star Polygon "<<endl;
           cout<<" Base Length: " << bl <<endl;
           cout<<" Length Long: " << l1 <<endl;
           cout<<" Length Short:" << l2 <<endl;
           cout<< setfill('-')<<setw(30)<<'-'<<endl;
           cout<< endl;
          
           h1 = sqrt(pow(l1, 2.00) - pow(bl, 2.0) / 4.00);
           h2 = sqrt((pow(l2, 2.00)) - (pow(bl, 2.0) / 4.00));
           d = 2.00 * h1 + bl * (1.00 + sqrt(2.00));
           p = 8.00 * (l2 + l1);
           a = 2.00 * bl * (bl * (1.00 + sqrt(2.00)) + (h1 + h2));
          
           cout<<" Height Long: "<< h1 << endl;
           cout<<" Height Short:"<< h2 << endl;
           cout<<" Diameter : " << d << endl;
           cout<<" Perimeter: " << p << endl;
           cout<<" Area: " << a << endl;
       }
  
   }else if(s == 't' || s == 'T' || s == '3')
   {
       cout<<" Threestar Polygon Calculator "<<endl;
       cout<<setfill('-')<<setw(30)<<'-'<<endl;
       cout<< endl;
      
       cout<<" Edge Length Valid range [1.00 < edge length < 132.00]"<< endl;
       cout<<" Edge Length: ";
       cin>> el;
       cout<< endl;
      
       cout<<" Inner Angle (degrees) Valid range [0.00 < edge legnth < 60.00]"<< endl;
       cout<<" Inner angle (degrees): ";
       cin>> ia;
       cout<< endl;
       cout<<setfill('-')<<setw(30)<<'-'<<endl;
      
       if (el < 1.00 || el > 132.00 || ia < 0.00 || ia > 60.00)
       {
           cout<<" Invalid number "<<endl;
       }
       else
       {
           cout<<" Calculations for a Threestar Polygon "<<endl;
           cout<<" Edge Length: " << el <<endl;
           cout<<" Outer angle: " << 120.00 + ia <<endl;
           cout<<" Inner angle: " << ia <<endl;
           cout<<setfill('-')<<setw(30)<<'-'<<endl;
          
           sb = sqrt((2.00 * pow(el, 2.00)) * (1.00 - cos(ia * (pi / 180.00))));
           sh = sqrt((4.00 * pow(el, 2.00) - pow(sb, 2.00)) / 4.00);
           cl = sqrt(2.00 * pow(el, 2.00) * (1.00 - cos ((120.00+ia) * (pi / 180.00))));
           h = (sqrt(3.00) / (2) * cl);
           P = 6.00 * el;
           A = (3.00 / 2.00) * sh * sb + (sqrt(3.00) / 4.00) * pow(sb, 2.00);
          
           cout<< "Spike base: " << sb <<endl;
           cout<< "Spike height: " << sh <<endl;
           cout<< "Chord length: " << cl <<endl;
           cout<< "Height: " << h <<endl;
           cout<< "Perimeter: " << P <<endl;
           cout<< "Area: " << A <<endl;
       }
  
   }else if (s == 'p' || s == 'P'){
  
       cout<<"Polygram Calculator"<<endl;
       cout<<setfill('-')<<setw(30)<<'-'<<endl;
       cout<< endl;
      
       cout<<" Point Count Valid range [3.00 < point count < 100.00]"<< endl;
       cout<<" Point count: ";
       cin>> pc;
       cout<< endl;
      
       cout<<" Edge Length Valid range [1.00 < edge length < 132.00]"<<endl;
       cout<<" Edge Length: ";
       cin>> elp;
       cout<< endl;
      
       cout<<" Outer Angle Valid range [0.00 < outer angle < 60.00]"<<endl;
       cout<<" Outer angle: ";
       cin>> oa;
       cout<< endl;
       cout<<setfill('-')<<setw(30)<<'-'<<endl;
      
       if (pc < 3.00 || pc > 100.00 || elp < 1.00 || elp > 132.00 || oa < 1.00 || bl > 60.00)
       {
           cout<<" Error - invalid entry "<<endl;
           cout<<endl;
       }
      
       else
       {
           cout<< "Calculations for Polygram" <<endl;
           cout<< "Point count: " << pc <<endl;
           cout<< "Edge Length: " << elp <<endl;
           cout<< "Outer angle: " << oa <<endl;
           cout<<setfill('-')<<setw(30)<<'-'<<endl;
          
           iap = oa - 360.00 / pc;
           blp = sqrt(2.00 * pow(elp, 2.00) * (1.00 - cos(iap * (pi / 180.00))));
           shp = sqrt(((4 * pow(elp, 2.00)) - pow(bsp, 2.00)) / 4.00);
           pp = 2 * pc * elp;
           ap = (pc * pow(bsp, 2.00)) / (4 * tan(pi/pc)) + (pc * shp*(bsp/2));
          
           cout<<" Inner angle: "<< iap <<endl;
           cout<<" Base length: "<< blp <<endl;
           cout<<" Chord length:"<<endl;
           cout<<" Spike Hieght:"<< shp <<endl;
           cout<<" Perimeter: " << pp <<endl;
           cout<<" Area: " << ap <<endl;
      
       }
   }
   else
   {
       cout<<"Error - invalid entry"<<endl;
       cout<<endl;
   }
  
   cout <<" Thank you for using Rebel Alliance Computational Support "<<endl;
   cout <<" May the Force be with you ! "<<endl;
   cout <<" * "<<endl;
   cout <<" * *** * "<<endl;
   cout <<" * * * * * "<<endl;
   cout <<" * ** * "<<endl;
   cout <<" ** * ** "<<endl;
   cout <<" *** *** *** "<<endl;
   cout <<" **** *** **** "<<endl;
   cout <<" ***** *** ****** "<<endl;
   cout <<" ********************** "<<endl;
   cout <<" ******************** "<<endl;
   cout <<" ****************** "<<endl;
   cout <<" ************** "<<endl;
   cout<<endl;
   return 0;
}

/* OUTPUT */


/* PLEASE UPVOTE */

Add a comment
Know the answer?
Add Answer to:
1.- i need help with my code because it appears me "main.cpp:77:7: error: expected unqualified-id before...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT