The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 2 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Can you help me with this code? I have 5 different outputs listed below. I only need number 5 to be corrected but output 1 - 4 still need to be correct after any code changes.
Â
Here is my code:
Â
#include <iostream>
Â
using namespace std;
Â
int main() {
int arrowBaseHeight = 0;
int arrowBaseWidth = 0;
int arrowHeadWidth = 0;
int i, j;
Â
cout << "Enter arrow base height: " << endl;
cin >> arrowBaseHeight;
Â
cout << "Enter arrow base width: " << endl;
cin >> arrowBaseWidth;
Â
cout << "Enter arrow head width: " << endl;
cin >> arrowHeadWidth;
Â
Â
// Draw arrow base
while(arrowBaseHeight--)
Â
{ for(i=arrowBaseWidth; i>0; i--)
Â
{ cout << "*";}
Â
cout << endl;}
Â
// Draw arrow head
Â
while(arrowHeadWidth)
Â
{
Â
for(i=arrowHeadWidth; i>0; i--)
Â
cout<< "*";
Â
cout << endl;
Â
arrowHeadWidth--;
Â
}
return 0;
}
Â
1. Compare output - Correct
Input
5
2
4
Â
Your output
Enter arrow base height:Â
Enter arrow base width:Â
Enter arrow head width:Â
**
**
**
**
**
****
***
**
*
Â
2. Compare output - Correct
Input
2
3
4
Your output
Enter arrow base height:Â
Enter arrow base width:Â
Enter arrow head width:Â
***
***
****
***
**
*
Â
3. Compare output - Correct
Input
3
3
7
Your output
Enter arrow base height:Â
Enter arrow base width:Â
Enter arrow head width:Â
***
***
***
*******
******
*****
****
***
**
*
Â
4. Compare output - Correct
Input
5
1
3
Your output
Enter arrow base height:Â
Enter arrow base width:Â
Enter arrow head width:Â
*
*
*
*
*
***
**
*
Â
5. Compare output
Â
Input
2
4
3
4
8
Â
Your output
Enter arrow base height:Â
Enter arrow base width:Â
Enter arrow head width:Â
****
****
***
**
*
Â
Expected output
Enter arrow base height:Â
Enter arrow base width:Â
Enter arrow head width:Â
Enter arrow head width:Â
Enter arrow head width:Â
****
****
********
*******
******
*****
****
***
**
*
Â
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly