The Problem here is that when i write a double variable then a int variable i get no out put and are stuck waiting
Code:
#include<iostream>
#include<windows.h>
#include<conio.h>
using namespace std;
double input(double, double);
int input(int, int);
double input(double, int);
//OVERLOADING ADDITION//
int main()
{
cout.setf(ios::showpoint);
cout.setf(ios::showpos);
cout.setf(ios::fixed);
cout.precision(2);
int x = 0;
int y = 0;
int n = 0;
int run = 1;
double dnumber;
int inumber;
double dnumber2;
int inumber2;
char c;
double danswer =0;
int ianswer =0;
while(run == 1)
{
while(n < 2)
{
cout <<"Do you want the number to be decimal placed or whole number <D> <W>?:";
for(;;)
{
if(n == 2)
{
system("cls");
break;
}
c=toupper(getch());
if(c == 'D')
{
if(x == 1)
{
system("cls");
cout <<"Input a number:";
cin >> dnumber2;
n = 2;
x = 2;
c = ' ';
}
if(x == 0)
{
system("cls");
cout <<"Input a number:";
cin >> dnumber;
n = n++;
x = 1;
c = ' ';
system("cls");
if(y == 0)
{
cout <<"Do you want the number to be decimal placed or whole number <D> <W>?:";
}
}
}
else if(c == 'W')
{
if(y == 1)
{
system("cls");
cout <<"Input a number:";
cin >> inumber2;
n = 2;
y = 2;
c = ' ';
}
if(y == 0)
{
system("cls");
cout <<"Input a number:";
cin >> inumber;
n = n++;
y = 1;
c = ' ';
system("cls");
if(x == 0)
{
cout <<"Do you want the number to be decimal placed or whole number <D> <W>?:";
}
}
}
}//for loop
} // While n < 2
if(x == 1 && y == 1)
{
danswer = input(dnumber,inumber);
cout << danswer << endl;
system("PAUSE");
x = 0; n = 0; y = 0; dnumber = 0; inumber = 0; ianswer = 0; inumber2 = 0; dnumber2 = 0; danswer = 0; c = ' ';
}
else if(x == 0 && y ==2)
{
ianswer = input(inumber,inumber2);
cout << ianswer << endl;
system("PAUSE");
x = 0; n = 0; y = 0; dnumber = 0; inumber = 0; ianswer = 0; inumber2 = 0; dnumber2 = 0; danswer = 0; c = ' ';
}
else if( x == 2 && y == 0)
{
danswer = input(dnumber,dnumber2);
cout << danswer << endl;
system("PAUSE");
x = 0; n = 0; y = 0; dnumber = 0; inumber = 0; ianswer = 0; inumber2 = 0; dnumber2 = 0; danswer = 0; c = ' ';
}
system("cls");
cout << "Do you wish to run this program again? <N> <Y>:";
for(;;)
{
c = toupper(getch());
if(c == 'N')
{
run = 0;
break;
}
else if(c == 'Y')
{
run = 1;
break;
}
}
system("cls");
} // While Run
return 0;
} // End main
double input(double num1, double num2)
{
double num3 = num1 + num2;
return(num3);
}
double input(double num1, int num2)
{
double num4 = (double) num2; //Even with out type casting same problem
double num3 = num4 + num1;
return(num3);
}
int input(int num1, int num2)
{
return(num1 + num2);
}