C++ :: Add And Minus From Text File Not Give Right Value

Feb 5, 2014

I'm creating a bank system.

So I know to make a deposit to the balance, which add ups what is the balance to i have add.

When i run the deposit function, its work well in some ways. If balance(text file) has the value 10, add i addSum 20, the balance will become 30, same as the text file will become 30. so its work well to add positive number.

Code:
double deposit(double balance) {
double addSum = 0;
system("CLS");
cout<< "Welcome to deposit."<<endl;
cout<<"Enter a sum you wish to add to your account:";

[code]...

When I withdraw from 30 which is the balance, then i takeSum, for example i take away 30. The balance will become 30 - 30 = 0 When i make another withdraw from example -150, it will be -150.Which shows correct.

But when i make a deposit from -150 and i addSum 130, the balance shows -500, and it should had been -20.

Code:
double withdraw(double balance) {
double takeSum = 0;
system("CLS");
cout<< "Welcome to withdraw."<<endl;
cout<<"Enter a sum you wish to take away from your account:";

[code]...

View 2 Replies


ADVERTISEMENT

C++ :: Add And Minus From Text File Not Giving Right Value

Feb 5, 2014

I'm creating a bank system. So I know to make a deposit to the balance, which add ups what is the balance to i have add.

When i run the deposit function, its work well in some ways. If balance(text file) has the value 10, add i addSum 20, the balance will become 30, same as the text file will become 30. so its work well to add positive number.

double deposit(double balance){
double addSum = 0;
system("CLS");
cout<< "Welcome to deposit."<<endl;
cout<<"Enter a sum you wish to add to your account:";

[Code] .......

When I withdraw from 30 which is the balance, then i takeSum, for example i take away 30. The balance will become 30 - 30 = 0

When i make another withdraw from example -150, it will be -150.

Which shows correct.

But when i make a deposit from -150 and i addSum 130, the balance shows -500, and it should had been -20.

double withdraw(double balance) {
double takeSum = 0;
system("CLS");
cout<< "Welcome to withdraw."<<endl;
cout<<"Enter a sum you wish to take away from your account:";
cout << balance << '

[Code] .....

What is causing this problem, also when function deposit and withdraw close, it goes to readBalance function, should go to menu.

double readBalance(double balance) {
int option;
system("CLS");
cout<<"Welcome to balance."<<endl;
cout<<"Your balance is:"<<endl;

[Code] .....

View 1 Replies View Related

C/C++ :: How To Give A Color To The Text That Displayed In Output Screen

Jan 27, 2013

i am using c++v30.5 version i want red color text in in my output screen . i viewed various site but the result is 0 ,wat to do?

View 2 Replies View Related

C++ :: XML File - ReadFile Function Does Not Give Right Values

Aug 21, 2014

I am trying to read this xml file. This readFile function does not give me right values. Only to use cstring..no pointers or other libs such as xml libs

void readFile(char file[], ifstream& read){
char line[chr_len];
read.open(file, ios::in);

if(read.fail())
cout<<"Sorry could not read";

[Code] ....

Also how can i only read the values..not the tags?

View 8 Replies View Related

C++ :: Plus Or Minus Notation

Aug 4, 2013

Is there a simple notation to check if a value is within a plus or minus range?

E.g.
//I read a value A. delay(50); //Read value again -calling this value B delay(50);
//Read value again -calling this value C delay(50); //Read value again -calling this value D delay(50);
//Read value again -calling this value E
Check IF first value A is within 5 of the value B and within 5 of value C, etc.

I can think of a few round about ways of doing this but is there any simple "equals to plus or minus" notation? (what I actually want to do is to check a lot more values than this and it will get very complicated with any of my solutions)....

View 4 Replies View Related

C++ :: T Minus Loops - Variable Index Declaration

Apr 25, 2014

(while)

T minus 10 and counting
T minus 9 and counting
T minus 8 and counting
T minus 7 and counting
T minus 6 and counting
T minus 5 and counting
T minus 4 and counting
T minus 3 and counting
T minus 2 and counting
T minus 1 and counting

Declare the following index before the while loop:

int index = 10;

Correctly code a while statement below using the variable index as defined above, to produce the output shown above.

So this is what my code looks like... I also have to convert this same loop into a do while and for loop. So if I can get this one right I think the others should come relatively easy.

while (int index >= 10) {
cout << "T minus " << index;
index--;
}

View 4 Replies View Related

C/C++ :: Two Arrays Merging Into New Array Minus Duplicates

Mar 9, 2013

I have same question as posted by holla and Iam not sure about merging the contents of 2 sorted arrays into another array without duplication of values.

View 9 Replies View Related

C :: Original Text File / Generate Another File With Text Content In Upper Case

Nov 29, 2014

Code software that, from an original text file, generate another file with the text content in upper case.For exemple:

entrence:

luke
tom
alex

outings:

LUKE
TOM
ALEX

My code so far:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
}

[code]....

View 2 Replies View Related

C/C++ :: Program That Opens Text File And Checks Usernames Listed In Text Files?

Jun 5, 2014

I want to make a program that opens a text file and checks the usernames listed in the text files to see if the names are registered on a site such as twitter. How easy would this be to make, what things would I need to know?

View 4 Replies View Related

C++ :: Getline - Get Text File And Read Only First 100 Lines Of Text Content

May 31, 2013

I am trying to get text file and read only first 100 lines of the text content using c/c++. how can i do it?

is it something like string line;
getline(stream,line);

??

View 7 Replies View Related

C++ :: Filter Text Enclosed In Specific Tags From Text File?

Aug 30, 2013

I have a huge text file in following format:

{Bunch of text
.
.
}

[Code].....

I want to extract Text1, Text2, Text3, Text4,..., Text600 in the output file. How can i achieve this?

/* BTW, I am not getting my homework done here. I am an ex-programmer, who has now moved to marketing for some time now, and today, I encountered this problem, which I believe can be solved easily through programming. */

View 3 Replies View Related

C/C++ :: Delete Text From File And Than Shift The Rest Of The Text Upward

Aug 31, 2014

i want to create 100 gmail accounts instantaneously....what i want from you guys is i have written a program that create a text file i want that once i give the program the imput of 1 it should delete the first 3 lines from the file i.e. the first account details coz that is already been created and shift the rest of it 3 lines upwards after that i'll write a javascript that will automatically fill and create the accounts with those names in web browser.....my lil program is here:

#‎include <stdio.h>
#include <conio.h>
main()

[Code]....

View 1 Replies View Related

C :: Calculate Final Grade By Adding 4 Numbers Minus Lowest Grade And Dividing By 3

Apr 7, 2013

I'm writing a program to calculate a final grade by adding 4 numbers minus the lowest grade and dividing by 3. My knowledge in c is not extensive I thought that a simple assigment operator would do the job but I'm getting a strange large numbers in the execution.

Code:
#include <stdio.h>
#include <stdlib.h>
main(){
int eg, g1, g2, g3, g4, fg, s1, s2, sg;

[Code] ....

View 4 Replies View Related

C++ :: Extracting Specific Lines Of Text From A Text File

Aug 2, 2014

I have a text file called (Test.txt) with the following text:

This is line one
This is line two
This is line three

How do I go about writing a program that will print a line of text (e.g. "This in line two" on the console screen?

All I can seem to do is display the entire text file.

View 6 Replies View Related

C# :: Give Image Name As Sequence Number?

Nov 18, 2014

I'm saving the images in folder by using:

webClient.DownloadFile(href, sourcepath);

I don't want to give name as Current date and time..shown in given below code

string sub = @"Gadhada";
DirectoryInfo subFolder = dir1.CreateSubdirectory(sub);
Imagename = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() +

[Code].....

I want to save my imagename as 1.jpg, 2.jpg, 3.jpg.

View 1 Replies View Related

C/C++ :: How To Give Validation For Character String

Aug 26, 2013

If i have character string 'char name[30]' how to give validation for the name entered by user?

View 4 Replies View Related

C Sharp :: How To Give Backcolor To The Button

Jul 14, 2014

I am designing a form ..in wich i used 3 buttons...from these 3 butons ,i wanna give backcolor to button1 . How to give it a backcolor?

View 1 Replies View Related

C/C++ :: RAM Does Not Give A Valid Preprocessing Token

May 2, 2014

#define PROJECT_ID ram  
#define QUOTES(FILENAME)  #FILENAME
#define DATA_VAR_FILENAME(PROJECT_ID) QUOTES(../##PROJECT_ID##_data_var.h)
#define DATA_VAR_FILE(PROJECT_ID) DATA_VAR_FILENAME(PROJECT_ID)
#define CUST_DATA_VAR_FILENAME DATA_VAR_FILE(PROJECT_ID)

When I tried to include CUST_DATA_VAR_FILENAME like below
#include CUST_DATA_VAR_FILENAME

Will get below error
error: pasting "/" and "ram" does not give a valid preprocessing token

View 1 Replies View Related

C Sharp :: How To Give Scroll Bar For Group Box

Oct 11, 2012

Is there any methods to add scroll bar for group box

My code scenerio is: I have many groupbox in form, all group box will be appears in same place and also height and width is fixed. I'm doing group box visible true/false according to condition.

So some groupbox ecxeeds the width and heighto so I want to put this all in scroll Bar

View 2 Replies View Related

C++ :: Give Output To Child Process

Apr 15, 2012

I'm trying to build a basic shell for Unix. This is the code I use to create a new process:

Code:
pid = fork();
if (pid == 0) {
setpgrp();
complexCommand(argv, isComplex);

[code] .....

Where complexCommand is a function that handles the command (uses execvp after generating the correct string out of argv). My problem is that after if while in the shell I use a program that needs to print to the screen and handle input, it doesn't work as expected. To test this, I built this small program:

Code:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main() {
int x1, x2;

[code] ....

And when I use the shell I built to run it, the output is only "Enter 2 numbers" for one time. It doesn't print the result, or anything else. Is there anything I need to do in the parent process (my shell in this case) to give the child the output?

View 2 Replies View Related

C++ :: How To Give Database Connection To Code

Apr 11, 2013

how to give a database connection to a c++ code i am using turbo c++ as an editor and if i have oracle 11g client, odbc as a driver , what else i require and how to link these things in a code.

View 1 Replies View Related

C++ :: Std List - How To Get Value Of Element 2 Minus Element 1

Aug 23, 2012

I have an std list of type double.. and the list is always guaranteed to have just 2 elements. I need to get the value of element 2 minus element 1. What is the least amount of code to accomplish that?

I tried this:

Code:
list<double> dList;
dList.push_back(1.0);
dList.push_back(2.0);
list<double>::iterator iter = dList.begin();
list<double>::iterator iter2 = dList.end();
double result = *iter2 - *iter;

But this code does not work. Why not?

View 6 Replies View Related

C++ :: Find X And Y Groups Integers And When Added Give Sum Of Z

Jan 26, 2013

You are given 3 integers x,y,z. you must find all groups of x integers until y, that when added give a sum of z.

View 2 Replies View Related

C++ :: How To Give Fraction Object In S String Via Template

May 9, 2014

I am trying to give fraction object in s string via template.

struct Fr // simple Fraction {
int num;
int denom;
Fr(int i,int j) {

[Code] ....

View 10 Replies View Related

C++ :: Don't Give Correct Location Of Max / Min Number In Array

Nov 8, 2013

All my code is good, except the functions: findMacLoc and findMinLoc .They don't give me the correct array location of the max/min number in the array.I know is something simple I need to tweak in those two functions.

#include <iostream>
#include <time.h>
using namespace std;
void printArray(int a [], int & size)
{
int i;
for (i = 0; i < size; i++)
cout << a[i] << " ";

[code].....

View 2 Replies View Related

C++ :: Program That Will Give Multiple Calculation Results

Apr 4, 2013

I need to write a program that will give me multiple calculation results.

#include <iostream>
using namespace std;
int main () {
int x = 8;
int y = 7;

[Code] ....

It only calculates the last two numbers: 1 and 0, so therefor it gives me 1.

But i need to calculate x and y each time they are smaller(incremented) by one digit.

Please note that the int calculation formula needs to stay.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved