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

Need help with this shape program this what I got so far but its not close to wo

ID: 3646614 • Letter: N

Question


Need help with this shape program this what I got so far but its not close to working.



#include <iostream>
#include <iomanip>
#include <cmath>
#include<string>

using namespace std;

void triangle1(int p);
void triangle2(int p);
void triangle3(int p);
void triangle4(int p);
void diagonal(int p);


void triangle1(int p)
{
for(int i=0;i<=p;++i)
{
for(int j=0;j<i;++j)
{
cout<<"*";
}

}
}
void triangle2(int p)
{
for(int i=p;i>0;--i)
{
for(int j=0;j<i;++j)
{
cout<<"*";
}

}
}
void triangle3(int p)
{
for(int i=p;i>0;--i)
{
for(int j=0;j<i;++j)
{
cout<<"*";
}

for(int r=p;r>=i;--r)
{
cout<<" ";
}
}
}
void triangle4(int p)
{
for(int i=0;i<=p;++i)
{
for(int r=p;r>i;--r)
{
cout<<" ";
}
for(int j=0;j<i;++j)
{
cout<<"*";
}

}
}
void diagonal(int p)
{
for(int i=0;i<p;++i)
{
cout<<"*";

}
}
}
class shape
{
void main(String[] args)
{
String s=args[0];
int n=Integer.parseInt(args[1]);
String s1="triangle1";
System.out.println(s);
draws obj=new draws();
if(s==s1)
{
obj.triangle1(n);
}
if(s=="triangle2")
{
obj.triangle2(n);
}
if(s=="triangle3")
obj.triangle3(n);
if(s=="triangle4")
obj.triangle4(n);
if(s=="diagonalup" | s=="diagonaldown")
obj.diagonal(n);

}

Explanation / Answer

Made several changes in program Problems: }-one was misplaced String with S capital at several places Integer.paseInt was not working Final program #include #include #include #include using namespace std; void triangle1(int p); void triangle2(int p); void triangle3(int p); void triangle4(int p); void diagonal(int p); void triangle1(int p) { for(int i=0;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote