Help plz

k so im doing this assignment that if u enter the coordinates of a shape it displays it filled in with "*", i just cant figure out how to do that. I made a program that displays the triangle with equal size sides, but cant do it when random sides are put in, so far i have:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
Exercise 4
Group square plus: Shane McGuire
*/
#include <iostream>
#include <fstream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
	double s, r, t, q, i, j,;
    double x, y,x2,y2,x3,y3,x4,y4,count;
    double sidea, sideb;
    double hypo=0;
	char choice;
	bool quit;
	
	cout << "This program allows you make a square, "
    	<< "a rectangle, and a triangle."
    	<< endl;
	do
	{
    	cout << "Enter: s, r, t, or q to quit" << endl;
    	cin >> choice;
    	switch(choice)
    	{
                  	case 's':
                  	case 'S':
                       	
                         	cout << "Enter coordinates x y:"<<endl;
                         	cin >> x >> y;
                            cin >> x2 >>y2;
                            cin >> x3 >>y3;
                            cin >> x4 >>y4;  	
                       	cout << "Test Square." << endl;
                       	                         	cout << x << y;
                            cout<< x2 <<y2;
                            cout << x3 <<y3;
                            cout << x4 <<y4;  
                       	break;
                  	case 'r':
                  	case 'R':

                         	cout << "Enter coordinates x y:"<<endl;
                            cin >> x >> y;
                            cin >> x2 >>y2;
                            cin >> x3 >>y3;
                            cin >> x4 >>y4;  
                        	
                       	cout << "Test Rectangle." << endl;
                       	break;
                  	case 't':
                  	case 'T':
                         	cout << "Enter coordinates x y:"<<endl;
                         	cin >> x >> y;
                            cin >> x2 >>y2;
                            cin >> x3 >>y3;
                            sidea=x2-x;
                            sideb=y3-y;
                            
                            
                            hypo=sqrt((sidea*sidea)+(sideb*sideb));
                            for (int num=0;num<sidea-1;num++){
                              cout<<"*"<<endl;
                              }
                            
                            for (int wow=0;wow<sideb;wow++){
                                 cout<<"*";}
                            
                              
                        	
                       	cout << "Test Triangle." << hypo<< endl;
                       	break;
                  	case 'q':
                  	case 'Q':
                       	cout << "Program is ending."
                            	<< endl
                            	<< "Press enter.";
                       	quit = true;
                       	break;
                  	default:
                          	cout << "Error: Invalid input." << endl;
                          	quit = false;
                          	break;
    	}
	}
	while(!quit);
	cin.ignore();
	cin.get();
	return 0;
}


so i only have the sides done dont know how to do the hypotenuse
----
so when u put in
5 6
11 6
5 15
it should output something like
*
**
***
*****
*******
*********
----

Last edited on
Topic archived. No new replies allowed.