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.
#include "stdafx.h"
#include <iostream>
#include <iomanip>
usingnamespace 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;
}