
15-Oct-2007, 10:39
|
|
New Member
|
|
Join Date: Oct 2007
Posts: 12
|
|
Flowchart Problem
..i have a problem concerning flowchart.. i dont know how to make a flowchart on this code....
#include <conio.h>
#include <stdio.h>
#define one gotoxy(3, 11); textattr(BLACK<<4|WHITE); cprintf(" 1 ");
#define two gotoxy(7, 11); textattr(BLACK<<4|WHITE); cprintf(" 2 ");
#define three gotoxy(11,11); textattr(BLACK<<4|WHITE); cprintf(" 3 ");
#define four gotoxy(3, 9); textattr(BLACK<<4|WHITE); cprintf(" 4 ");
#define five gotoxy(7, 9); textattr(BLACK<<4|WHITE); cprintf(" 5 ");
#define six gotoxy(11, 9); textattr(BLACK<<4|WHITE); cprintf(" 6 ");
#define seven gotoxy(3, 7); textattr(BLACK<<4|WHITE); cprintf(" 7 ");
#define eight gotoxy(7, 7); textattr(BLACK<<4|WHITE); cprintf(" 8 ");
#define nine gotoxy(11, 7); textattr(BLACK<<4|WHITE); cprintf(" 9 ");
#define zero gotoxy(15,11); textattr(BLACK<<4|WHITE); cprintf(" 0 ");
#define plus gotoxy(15, 5); textattr(BLACK<<4|WHITE); cprintf(" + ");
#define minus gotoxy(11, 5); textattr(BLACK<<4|WHITE); cprintf(" - ");
#define divide gotoxy(3, 5); textattr(BLACK<<4|WHITE); cprintf(" / ");
#define multiply gotoxy(7, 5); textattr(BLACK<<4|WHITE); cprintf(" * ");
#define ENTER gotoxy(15, 9); textattr(BLACK<<4|WHITE); cprintf(" Enter ");
#define C gotoxy(18, 7); textattr(BLACK<<4|WHITE); cprintf("C");
#define SHOW_ printf(" ");
void calcuForm (void);
void printSol1 (double value);
void printSol2 (double solution);
void printSol3(double b);
void entranceFace (void);
void calcuForm (void)
{
gotoxy(22,2); textattr(BLINK|YELLOW<<4|BLACK); cprintf("SIMPLE ARITHMETIC CALCULATOR PROGRAM");
gotoxy(1, 4); printf("ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵");
gotoxy(1, 5); printf("³³ / ³ * ³ - ³ + ³ ³³");
gotoxy(1, 6); printf("³ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÁÄÄÄ´³");
gotoxy(1, 7); printf("³³ 7 ³ 8 ³ 9 ³ C ³³");
gotoxy(1, 8); printf("³ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÄÄÄÄ´³");
gotoxy(1, 9); printf("³³ 4 ³ 5 ³ 6 ³ Enter ³³");
gotoxy(1, 10); printf("³ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄÄÄÄÄ´³");
gotoxy(1, 11); printf("³³ 1 ³ 2 ³ 3 ³ 0 ³---³³");
gotoxy(1, 12); printf("ÀÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÙ");
gotoxy(1, 13); printf("³ ³");
gotoxy(1, 14); printf("ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵");
gotoxy(25, 20); textattr(BLINK| BLACK<<4| WHITE); cprintf("Press the ESC key to exit...");
return;
}
void main()
{
double value = 0;
double solution = 0;
char symbol = '';
int operate_a = 0, negative = 0;
int x = 0;
int y = 0;
enum operate
{enone, edivide,eplus, emultiply, enegative, eminus};
int erase[10] = {0};
clrscr();
for(;;)
{
for(x=0; x<=10; x++)
{
if(x==1){solution = 0;}
textbackground(3);
textcolor(1);
clrscr();
if(x==10 && symbol != '\x1B' && symbol != '+' && symbol != '-'
&& symbol != '*' && symbol != '/' && symbol != '\r' && symbol != '\x08'){ x--;
symbol = '\x0';
}
switch(symbol)
{
case '1': one; if(x==1 && negative != enegative)
{solution += 1; erase[x] = solution;}
else if(x==1 && negative == enegative)
{solution = (-1); erase[x] = 1;}
else { solution = ((solution*10)+1);
erase[x] = 1;}
break;
case '2': two; if(x==1 && negative != enegative)
{solution += 2; erase[x] = solution;}
else if(x==1 && negative == enegative)
{solution = (-2); erase[x] = 2;}
else { solution = ((solution*10)+2);
erase[x] = 2;}
break;
case '3': three; if(x==1 && negative != enegative)
{solution += 3; erase[x] = solution;}
else if(x==1 && negative == enegative)
{solution = (-3); erase[x] = 3;}
else { solution = ((solution*10)+3);
erase[x] = 3;}
break;
case '4': four; if(x==1 && negative != enegative)
{solution += 4; erase[x] = solution;}
else if(x==1 && negative == enegative)
{solution = (-4); erase[x] = 4;}
else { solution = ((solution*10)+4);
erase[x] = 4;}
break;
case '5': five; if(x==1 && negative != enegative)
{solution += 5; erase[x] = solution;}
else if(x==1 && negative == enegative)
{solution = (-5); erase[x] = 5;}
else { solution = ((solution*10)+5);
erase[x] = 5;}
break;
case '6': six; if(x==1 && negative != enegative)
{solution += 6; erase[x] = solution;}
else if(x==1 && negative == enegative)
{solution = (-6); erase[x] = 6;}
else { solution = ((solution*10)+6);
erase[x] = 6;}
break;
case '7': seven; if(x==1 && negative != enegative)
{solution += 7; erase[x] = solution;}
else if(x==1 && negative == enegative)
{solution = (-7); erase[x] = 7;}
else { solution = ((solution*10)+7);
erase[x] = 7;}
break;
case '8': eight; if(x==1 && negative != enegative)
{solution += 8; erase[x] = solution;}
else if(x==1 && negative == enegative)
{solution = (-8); erase[x] = 8;}
else { solution = ((solution*10)+8);
erase[x] = 8;}
break;
case '9': nine; if(x==1 && negative != enegative)
{solution += 9; erase[x] = solution;}
else if(x==1 && negative == enegative)
{solution = (-9); erase[x] = 9;}
else { solution = ((solution*10)+9);
erase[x] = 9;}
break;
case '0': zero; if(x==1 && negative != enegative)
{solution = 0;}
else if(x==1 && negative == enegative)
{solution = 0; erase[x] = 0;}
else { solution = ((solution*10));
erase[x] = 0;}
break;
case '+': plus; if(x!=1){value = solution;}
operate_a = eplus;
x = 0; negative = enone;
for(y=0;y<=10;y++)
{
erase[y]=0;
}
break;
case '-': minus; if(x!=1){value = solution; negative = enone;}
if(value){negative = enegative;}
operate_a = eminus;
x = 0; negative = enone;
for(y=0;y<=10;y++)
{
erase[y]=0;
}
break;
case '*': multiply; if(x!=1){value = solution;}
operate_a = emultiply;
x = 0; negative = enone;
for(y=0;y<=10;y++)
{
erase[y]=0;
}
break;
case '/': divide; if(x!=1){value = solution;}
operate_a = edivide;
x = 0; negative = enone;
for(y=0;y<=10;y++)
{
erase[y]=0;
}
break;
case '\x08': C; x--;
if(x==1 && solution!=0){solution = (solution - erase[x]);}
else if(solution!=0){solution = ((solution - erase[x])/10); }
x--;
}
{
if(symbol == '\x1B'){break;}
calcuForm();
if(symbol == '+' || symbol == '-' || symbol == '*' || symbol == '/')
{printSol1(value); x=0;
}
else if(symbol != '\r' && negative != enegative)
{
printSol2(solution);
}
else if(symbol != '\r' && negative == enegative)
{
printSol3(solution);
}
else if(symbol == '\r' && operate_a == eplus)
{
value += solution; x = 0; ENTER;
printSol1(value); operate_a = enone;
for(y=0;y<=19;y++)
{
erase[y]=0;
}
}
else if(symbol == '\r' && operate_a == eminus)
{
value -= solution; x = 0; ENTER;
printSol1(value); operate_a = enone;
for(y=0;y<=10;y++)
{
erase[y]=0;
}
}
else if(symbol == '\r' && operate_a == edivide)
{
if(solution != 0)
{
value /= solution; printSol1(value);
}
x = 0; ENTER;
operate_a = enone;
for(y=0;y<=10;y++)
{
erase[y]=0;
}
}
else if(symbol == '\r' && operate_a == emultiply)
{
value *= solution; x = 0; ENTER;
printSol1(value); operate_a = enone;
for(y=0;y<=19;y++)
{
erase[y]=0;
}
}
else {ENTER; printSol2(solution); }
}
{
switch(symbol)
{
default: SHOW_;
}
}
symbol = '\x0';
symbol = getch();
}
if (symbol == '\x1B'){break;}
}
}
void printSol1 (double value)
{
gotoxy(2, 13); printf("%18.2f", value);
return;
}
void printSol2 (double solution)
{
gotoxy(2, 13); printf("%18.2f", solution);
return;
}
void printSol3 (double solution)
{
gotoxy(2, 13); printf("%18.2f", -solution);
return;
}
........can anyone would like to help me?!..what will i do?..thank yoU!..i wait for replies!..its due will be on wednesday! and i like to have it tomorrow for me to finalise it!:cry:
Last edited by LuciWiz : 16-Oct-2007 at 14:11.
Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
|