Is there any way to make modifications to the command prompt in visual studio e.g change background color, font, borders etc.?


I'm just wondering is there any way I can add a border around this simple menu I created in the command prompt on visual studio, also modify other things like change the font and background color.



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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
  #include "stdafx.h"
 #include <iostream> 
 #include <iomanip>



using namespace std;

int main()
{
	
	
	
	
	int big, small0 , small1, value, count = 0;
	int list[12]; 
	int option;
	int sum = 0;
	int sum1 = 0;
	
	cout << "Enter 12 numbers : ";
	for (int i = 0; i < 12; i++)
	{

		cin >> list[i]; 

	}

	big = small0 = small1 = list[0];  

	do 
	{
		//various options in the menu
		cout << "\t\tMenu\n";
		cout << "\t0.Display\n";
		cout << "\t1.Total\n"; 
		cout << "\t2.Average\n";
		cout << "\t3.Largest\n"; 
		cout << "\t4.Smallest\n"; 
		cout << "\t5.Occurance of value\n";
		cout << "\t6.Multiply values by number entred\n"; 
		cout << "\t7.Reverse array\n"; 
		cout << "\t8.Minus smallest number in array from the 12 numbers /n";
		cout << "\t99.Exit\n"; 
		cout << "\t\t Option ? ";
		cin >> option; 

		switch (option) 
		{
		case 0:

			cout << "Contents\n"; 


			for (int i = 0; i < 12; i++) 
			{                            
				cout << list[i] << endl; 

			}
			break;

		case 1:

			cout << "Total"; 
			cout << "\n\n";

			for (int i = 0; i < 12; i++)
			{

				sum = list[i] + sum; //adds and stores the total in sum

			}

			//outputs sum to screen
			cout << sum;
			break;

		case 2:

			cout << "average\n"; //gets the average number of the numbers in the array

			for (int i = 0; i < 12; i++)
			{
				sum1 = list[i] + sum1; // gets the total of the numbers in the arry

			}
			//divides total by 12 to get the average
			cout << setprecision(1) << fixed << sum1 / 12;

			break;

		case 3:

			cout << "Largest\n"; //outputs largest integer in array to screen

			for (int i = 0; i < 12; i++)
			{
				if (list[i] > big) //big = 0 
				{

					big = list[i];  //compares biggest value with current element
				}

			}

			cout << big; //outputs biggest element to screen

			break;

		case 4:

			cout << "Smallest\n";

			for (int i = 0; i < 12; i++)
			{
				if (list[i] < small0)
				{
					small0 = list[i]; //compares smallest value with current element
				}

			}

			cout << small0; //outputs smallest element to screen

			break;

		case 5:

			cout << "Occurances of value\n"; //how many times a number appears in the array

			cout << "Enter value to search for: \n";
			cin >> value; //enters number to view the occurances of it in the array

			for (int i = 0; i < 12; i++)
			{

				if (list[i] == value) //if an element in the array matches the value
				{

					{
						count++; //count increments
					}

				}

			}
			cout << value << " occurs " << count << " time(s)" << endl;
			break;

		case 6:
			// value is entred which multiplies all the elements in the array by that value
			cout << "Enter value that you wish to multiply the contents \n in the array by : \n";
			cin >> value; //value is entred

			for (int i = 0; i < 12; i++)
			{

				list[i] = value * list[i]; //value is multiplied by all the elements in list[i] and stored in list [i]

				cout << list[i] << endl; // the new numbers in list[i] are outputed to the screen
			}

			break;
		case 7:

			cout << "Reverse contents:\n"; //outputs numbers in array in reverse order to what they where inputed 

			for (int i = 11; i >= 0; i--) // i is incremented downwards from 11-0 rearranging the integers in reverse order
			{
				cout << list[i] << endl; // the new rearranged intergers are outputed to the screen
			}

			break;

		case 8:

			for (int i = 0; i < 12; i++)
			{
				if (list[i] < small1)
					//again the smallest value is found
				{

					small1 = list[i];

					 //stored in small
			
				}

				 //the elements in the array are then minused by small and stored back into the array
				list[i] = list[i] - small1;
				 //new elements in the array are outputed to the screen
				cout << list[i] << endl;
			}
			break;

		case 99: //exits the menu as the do while loop stays in the loop for everything except 99
			cout << "You are now exiting the menu, Goodbye.\n";
			break;

		default: //any number that isnt a case in the switch statment is an invalid option.
			cout << "Invalid option\n";
			break;
		}

	} while (option != 99);

	return 0;

}
Last edited on
A couple examples here on color.
Topic archived. No new replies allowed.