473,386 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

problems with my program again!

hello everyone!
my program is not working properly,
it is not summing the values that i entered.
It should take the double values and add them and also take strings and
makes the * as a multiplacation .

thanks !!!
begum
here is my program

#include<iostream>
#include<string>
#include<iomanip>
#define MAX_INPUT_SIZE 100
using namespace std;

char language;
char temp;
int i;
int k;
double i_error;
double no_star;
char e;
char s;
int main()
{
cout<<"<T>urkce or <E>nglish :";
cin>>language;

while(1)
{
if(language=='E' ||language=='e')
{
cout<<"Enter prices or <S>top:";
cin>>s;if(s =='S' ||s=='s') break;

}
else if(language=='T'||language=='t')
{
cout<<"Fiyat girin veya <Sdur:";
cin>>s;if(s =='S' ||s=='s') break;

}
char temp[MAX_INPUT_SIZE]; //input,
char array; //en basta hepsi NULL'a esit
char part1[MAX_INPUT_SIZE],part2[MAX_INPUT_SIZE] ;
// char array; // en basta hepsi NULL'a esit
int k=0;
int current_operand=1;
double sum, sum1, sum2, total;


if(i_error==0) //processing input
{
for(i=0; i<=MAX_INPUT_SIZE; i++)
{
if(temp[i]!='*'&&current_operand==1&&temp[i]!=NULL)
{
part1[i]=temp[i];
}
if(temp[i]!='*'&&current_operand==2&&temp[i]!=NULL)
{
part2[k]=temp[i];
k++;
}

if(temp[i]=='*')
{
current_operand=2;
}
}

sum1=atof(part1);
sum2=atof(part2);

if(no_star)
{
sum=sum1;
}
if(!no_star)
{
sum=sum1*sum2;
}

total=total+sum;
}

if(language=='E' ||language=='e')
{
cout<<"The total is "<<setw(12)<<total<< "$ and VAT is "
<<setw(12)<<total*(0.12)<<"$."<<endl;

}
if(language=='T'||language=='t')
{
cout<<"Toplam "<<setw(12)<<total<< "YTL ve
KDV"<<setw(12)<<total*(0.12)<<"YTL."<<endl;
}
if(language=='E'||language=='e')
{
cout<<"<N>ext or <Q>uit:" ;
}
if(language=='T'||language=='t')
{
cout<<"<D>evam veya <C>ikis:";
}

cin>>e;

if(e=='N'||e=='n'||e=='D'||e=='d')
{
system("cls");
}
if(e=='Q'||e=='q'||e=='C'||e=='c')
{
return 0;
}
return 0;
}
}

Dec 6 '06 #1
2 1239

"begum" <be*******@gmail.comwrote in message
news:11*********************@n67g2000cwd.googlegro ups.com...
hello everyone!
my program is not working properly,
it is not summing the values that i entered.
It should take the double values and add them and also take strings and
makes the * as a multiplacation .

thanks !!!
begum
here is my program
Ever heard of a debugger? Step through the program and see what it's doing.

Or add cout statements at key points to report whether you reach certain
points and what values exist at those points, to see where things are going
right/wrong.

-Howard
Dec 6 '06 #2
On 6 Dec 2006 11:56:16 -0800 in comp.lang.c++, "begum"
<be*******@gmail.comwrote,
>my program is not working properly,
it is not summing the values that i entered.
I see that you define:
char s;
Then later you have:
cout<<"Enter prices or <S>top:";
cin>>s;
So all that can be entered is a single char. How is the user supposed
to enter any prices, if he can enter only a single char?
char temp[MAX_INPUT_SIZE]; //input,
char array; //en basta hepsi NULL'a esit
char part1[MAX_INPUT_SIZE], part2[MAX_INPUT_SIZE];
These variables are never initialized or read in.
Also, it is a bad idea to have a variable named "array" that is not an
array.

Dec 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: nao921 | last post by:
Hi everyone, I am currently involved in a project that involves a windows client program written in delphi and a web application written in php. I have made several php pages for the delphi...
10
by: stu7 | last post by:
+ I have some problems with QT. I know that it is supposed to be useful for compiling cross-platform versions of a program, and that it has something to do with C++ ...not a problem so far. ...
7
by: jmac | last post by:
Greetings fellow programmers, I have created a C program that has a few bugs and would like to get some help with working them out. Here is a list of the problems that I am experiencing: -...
5
by: Madison Kelly | last post by:
Hi all, I have got to say that my first foray into postgresSQL is becoming a very madening experience... I am sure it is my own fault for not knowing very much but it seems that everything I...
2
by: Olaf Baeyens | last post by:
None of our clickonce applications seems to want to install. We tried it on a Windows 2000 server shared folder, and the clickonce log file tells us that some file is missing while it is absolutely...
2
by: Mike | last post by:
Hi, I am new to C and having problems with the following program. Basically I am trying to read some files, loading data structures into memory for latter searching. I am trying to use structres...
6
by: JNeko | last post by:
Hello all, awesome site! I guess I am technically not a beginner in JAVA, but from my code you would not realize it! I don’t expect anyone to help me with this, but I figure I might as well as try...
2
by: subsanta | last post by:
My computer has so many problems and ive looked around on the internet and ive managed to fix some of them. I know that i have a few viruses on my computer, but i cant get rid of them, in one case i...
4
by: dennijr | last post by:
sry its long, questions in the last sentance if u wanna jump to it. i just decided that i would include everything that led up to the problem i made a gif video that i wanted to put...
10
by: Cliff | last post by:
Greetings, I have been trying to teach myself C++ over the past few weeks and have finally came across a problem I could not fix. I made a simple program that prints out a square or rectangle...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.