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
|
#include <windows.h>
enum
{
black,
dark_blue,
dark_green,
dark_cyan,
dark_red,
dark_magenta,
dark_yellow,
light_gray,
dark_gray,
light_blue,
light_green,
light_cyan,
light_red,
light_magenta,
light_yellow,
white
};
int getcolors()
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(
GetStdHandle( STD_OUTPUT_HANDLE ),
&csbi
);
return csbi.wAttributes;
}
int getfgcolor()
{
return getcolors() & 0x0F;
}
int getbgcolor()
{
return getcolors() >> 4;
}
void setfgcolor( int color )
{
SetConsoleTextAttribute(
GetStdHandle( STD_OUTPUT_HANDLE ),
(getcolors() & 0xF0) | (color & 0x0F)
);
}
void setbgcolor( int color )
{
SetConsoleTextAttribute(
GetStdHandle( STD_OUTPUT_HANDLE ),
((color & 0x0F) << 4) | (getcolors() & 0x0F)
);
}
void setcolors( int fg, int bg )
{
SetConsoleTextAttribute(
GetStdHandle( STD_OUTPUT_HANDLE ),
((bg & 0x0F) << 4) | (fg & 0x0F)
);
}
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <windows.h>
int main() {
int currencyOption;
int initial_fg_color = getfgcolor();
int initial_bg_color = getbgcolor();
start:
setbgcolor( white );
system("cls");
setbgcolor( white );
setfgcolor( black );
printf("\n **************************************************");
printf("\n **************************************************");
printf("\n ** **");
printf("\n ** Enter the NUMBER from the below list **");
printf("\n ** of currency you wish to convert to US$ **");
printf("\n ** **");
printf("\n ** **");
printf("\n ** 1 = Australian dollars. **");
printf("\n ** 2 = British Pounds. **");
printf("\n ** 3 = Japanese yen. **");
printf("\n ** 4 = South African Rand. **");
printf("\n ** **");
printf("\n ** Enter Currency number: **");
printf("\n ** **");
printf("\n **************************************************");
printf("\n **************************************************");
printf("\n");
scanf("%d", ¤cyOption);
printf("\n");
float xrate;
if(currencyOption == 1) {
xrate=0.914;
printf("You want to convert Australian dollars to US$ \n"); }
if(currencyOption == 2) {
xrate=1.656;
printf("you want to convert British pounds to US$ \n"); }
if(currencyOption == 3) {
xrate=0.010;
printf("you want to convert Japanese yen to US$ \n"); }
if(currencyOption == 4){
xrate=.101;
printf("you want to convert vietnames dollars to US$ \n"); }
if(currencyOption > 4)
goto start;
sleep(3000);
system("cls");
setfgcolor( light_red );
printf("\n");
printf("\n **************************************************");
printf("\n **************************************************");
printf("\n ** **");
printf("\n ** Enter the amount you wish to convert to US$ **");
printf("\n ** **");
printf("\n **************************************************");
printf("\n **************************************************");
printf("\n");
float currencyvalue;
printf("\n");
scanf("%f",¤cyvalue);
int i=1;
float result[2];
int mult = i* 1;
result[i] = currencyvalue * xrate * mult;
printf("\n");
printf("\n");
printf("To Be Converted:- %10.2f\n\nExchange rate of:-%10.2f \n\nYou will recieve:-%10.2f US$\n--------------------------------------------------\n", currencyvalue, xrate, result[i]);
sleep(4000);
system("cls");
printf("\n");
int cont;
int y;
int n;
setfgcolor( light_green );
printf("\n **************************************************");
printf("\n ** **");
printf("\n ** Do you wish to perform another conversion **");
printf("\n ** Type 1 for yes 2 for no **");
printf("\n ** **");
printf("\n **************************************************");
printf("\n\n");
scanf("%d", &cont);
if(cont == 1)
goto start;
system("cls");
if(cont== 2){
printf("\n **************************************************\n\n");
printf(" HAVE A NICE DAY \n\n");
printf("\n **************************************************\n\n");
}
sleep(4000);
system("cls");
setfgcolor( light_blue );
printf("\n **************************************************");
printf("\n ** **");
printf("\n ** CODE written and compiled by Rodney Beadon **");
printf("\n ** **");
printf("\n **************************************************");
printf("\n\n\n");
sleep(5000);
system("cls");
return 0; }
|