Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Hunter Basinger Roman Numerals 5/5/17
- #include <iostream>
- #include <cstdlib>
- #include <windows.h>
- using namespace std;
- #include <time.h>
- #include <iomanip>
- void setFontSize(int FontSize)
- {
- CONSOLE_FONT_INFOEX info = {0};
- info.cbSize = sizeof(info);
- info.dwFontSize.Y = FontSize;
- info.FontWeight = FW_NORMAL;
- wcscpy(info.FaceName,L"Lucida Console");
- SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), NULL, &info);
- }
- void SetColor(int ForgC)
- {
- WORD wColor;
- HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- // we use csbi for the wattributes word.
- if(GetConsoleScreenBufferInfo(hStdOut, &csbi))
- {
- //mask out al but the background attribute, and add in the forground color
- wColor=(csbi.wAttributes & 0xF0) + (ForgC & 0x0F);
- SetConsoleTextAttribute(hStdOut, wColor);
- }return;
- }
- int RomanNumber(int Start, int End)
- {
- for(; Start <= End; Start++)
- {
- if(Start == 1)
- {
- SetColor(12);
- cout<<"1. I" << endl;
- }
- else if(Start == 2)
- {
- SetColor(4);
- cout<<"2. II" << endl;
- }
- else if(Start == 3)
- {
- SetColor(14);
- cout<<"3. III" << endl;
- }
- else if(Start == 4)
- {
- SetColor(10);
- cout<<"4. IV" << endl;
- }
- else if(Start == 5)
- {
- SetColor(3);
- cout<<"5. V" << endl;
- }
- else if(Start == 6)
- {
- SetColor(1);
- cout<<"6. VI" << endl;
- }
- else if(Start == 7)
- {
- SetColor(5);
- cout<<"7. VII" << endl;
- }
- else if(Start == 8)
- {
- SetColor(7);
- cout<<"8. VIII" << endl;
- }
- else if(Start == 9)
- {
- SetColor(13);
- cout<<"9. IX" << endl;
- }
- else
- {
- SetColor(15);
- cout<<"10. X" << endl;
- }
- }
- }
- int main(int argc, char** argv)
- {
- setFontSize(20);
- int i;
- int x;
- cout<<"\t ____________" <<endl;
- cout<<"\t| |" << endl;
- cout<<"\t|ROMAN NUMBER| " << endl;
- cout<<"\t|____________|"<< endl;
- cout<< endl;
- cout<<"During this program it will display the number and roman numberal equivalent." << endl;
- cout<<"This program will only display 1 - 10." << endl;
- cout<< endl;
- cout<<"Please choose the number you wish to start with: ";
- cin >> i;
- cout<< endl;
- if(i > 10 || i <= 0)
- {
- cout<<"Error! Error! Your number can't go higher than 10 or be lower than 1! Please re-enter." << endl;
- cout<<"Please chose the number you wish to start with: ";
- cin >> i;
- cout<< endl;
- }
- cout<<"Please choose the number you wish the end with: ";
- cin >> x;
- cout<< endl;
- SetColor(10);
- if(x > 10)
- {
- cout<<"Error! Error! Your number can't be higher than 10! Please re-enter." << endl;
- cout<<"Please choose the number you wish the end with: ";
- cin >> x;
- cout<< endl;
- }
- cout << endl;
- RomanNumber(i, x);
- SetColor(10);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement