473,804 Members | 3,804 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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<iostre am>
#include<string >
#include<iomani p>
#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_SI ZE; i++)
{
if(temp[i]!='*'&&current_ operand==1&&tem p[i]!=NULL)
{
part1[i]=temp[i];
}
if(temp[i]!='*'&&current_ operand==2&&tem p[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)<<to tal<< "$ and VAT is "
<<setw(12)<<tot al*(0.12)<<"$." <<endl;

}
if(language=='T '||language=='t ')
{
cout<<"Toplam "<<setw(12)<<to tal<< "YTL ve
KDV"<<setw(12)< <total*(0.12)<< "YTL."<<end l;
}
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 1255

"begum" <be*******@gmai l.comwrote in message
news:11******** *************@n 67g2000cwd.goog legroups.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*******@gmai l.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
2419
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 program to do requests via the http component from INDY. the problems I am having are: 1) the first request from delphi app to php web app is the authenication. In which user sends username + password to the php app. If authenication is valid, a...
10
3685
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. But - if QT compilies a program for Linux (my interest)... why do I have to install QT (again) to use it ? It seems it hasn't compiled -FOR- Linux at all, but is only using the Linux framework to run itself on_ acting more like a virus than a...
7
4122
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: - The program calls for the input to be added in one line (? 100 Smith 24.98), but my right now my program skips a line each time for example: ? 100
5
1234
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 have tried so far to improve performance has in fact made it a lot worse. Now my program dies after roughly 300 seconds of processing directories and updates take literally 10 time longer than inserts (which are themselves very slow). I am sorry...
2
4872
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 wrong, the file is there and is has all rights available. Copying it locally solves the trick. Another problem is the uninstall, one of the clickonce seems to have been installed and I find it back in the add/remove software list, but I cannot...
2
3279
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 and arrays of pointers to them. I have gotten the program to compile with gcc on WinXP. If the file i read doesnt have alot of records, it runs thru. But once i add more, it dies. In this program i have 4 files setup to read. The
6
1894
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 and ask. Any help is really appreciated; this should be a piece of cake…driving me crazy. I am writing a simple program (from a book for fun) that creates a deck of cards, shuffles them, gives the user a card, and asks if the next card will be...
2
2868
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 think i have one on my ipod "boot.exe" and i cant get rid of it. All of the antivirus programs ive tried either dont pick it up or cant scan my ipod. Den i have "copy.exe" which i dont know how to fix either. Task manager and regedit were...
4
4212
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 into a program, and i couldnt figure out how to get it into VB6. finally i found out that the Microsoft Internet Control would play the gif file if i located it with "webbrowser1.navigate" for example, so i did this. i decided it was working fine and...
10
1887
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 using the * character. The program was just for practice but I am having problems. My main problem is, in my program I use 4 functions to change or access two variables in my code. The variables are
0
9705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9576
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10310
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10074
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9138
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5515
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2983
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.