Hello, I am having trouble with getting my counters to work to count how many credit transactions and debit transactions there are.. UNless there is another way I can count them.. Could someone help me please...
Hello, I am having trouble with getting my counters to work to count how many credit transactions and debit transactions there are.. UNless there is another way I can count them.. Could someone help me please...
Last edited by tameeyore; 10-07-2004 at 07:05 PM.
For the love of jeebus use code tags!
(Look at the top of the forum to find out how)
Last edited by XSquared; 10-07-2004 at 06:42 PM.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
use code tags...try again
I am not sure how the code tags work.. Sorry I am new at this... I read abt them and did what it said unless I am not getting.. Sorry if this is wrong again...
Code:#include <stdio.h> #include <math.h> #define strt_blnce 2000.00 #define yrly_intrst .02 int main (int argc, char **argv){ float dpst, withdrw, withdrw2, blnce, crdt, dbt, intrst, finalblnce,blnce2; int date, opt; printf("Your current balance is $%1.2f \n", strt_blnce); printf("Banking program \n"); printf("1.) Deposit funds (credit transaction) \n"); printf("2.) Withdraw funds (debit transaction) \n"); printf("3.) Print statement of the acct \n"); printf("4.) Compute interest and exit program \n"); printf("Please indicate you option: "); scanf("%d",&opt); switch(opt){ case 1: crdt++; printf("Please enter a valid date from 1 to 31: "); scanf("%d", &date); printf("How much do you want to deposit? "); scanf("%f", &dpst); blnce = strt_blnce + dpst; printf("Your current balance is $%1.2f. \n", blnce); printf("Please indicate your option: "); scanf("%d", &opt); case 2: printf("Please enter a valid date from 1 to 31: "); scanf("%d", &date); printf("How much do you want to withdraw? "); scanf("%f", &withdrw); if (withdrw > blnce) { printf("Please enter a smaller amt. \n"); printf("How much do you want to withdraw? "); scanf("%f", &withdrw); }else blnce2 = blnce - withdrw; printf("Your current balance is $%1.2f. \n", blnce2); dbt++; printf("Please indicate your option: "); scanf("%d", &opt); case 3: printf("Please enter a valid date from 1 to 31: "); scanf("%d", &date); printf("Your current balance is $%1.2f. \n", blnce); printf("Number of credit transactions: %d \n ", crdt); printf("Number of debit trasactions: %d \n ", dbt ); printf("Please indicate your option: "); scanf("%d", &opt); case 4: printf("Statement of Account for October, 2004 \n"); printf("Number of credit transactions: %.2d \n ", crdt); printf("Number of debit transactions: %.2d \n ", dbt); intrst = blnce * yrly_intrst * 12; printf("Interest computed: $%1.2f \n", intrst); finalblnce = blnce + intrst; printf("Good Bye!! \n"); } return 0; }
Indentation...
Code:#include <stdio.h> #include <math.h> #define strt_blnce 2000.00 #define yrly_intrst .02 int main(int argc, char **argv) { float dpst, withdrw, withdrw2, blnce, crdt, dbt, intrst, finalblnce, blnce2; int date, opt; printf("Your current balance is $%1.2f \n", strt_blnce); printf("Banking program \n"); printf("1.) Deposit funds (credit transaction) \n"); printf("2.) Withdraw funds (debit transaction) \n"); printf("3.) Print statement of the acct \n"); printf("4.) Compute interest and exit program \n"); printf("Please indicate you option: "); scanf("%d", &opt); switch (opt) { case 1: crdt++; printf("Please enter a valid date from 1 to 31: "); scanf("%d", &date); printf("How much do you want to deposit? "); scanf("%f", &dpst); blnce = strt_blnce + dpst; printf("Your current balance is $%1.2f. \n", blnce); printf("Please indicate your option: "); scanf("%d", &opt); case 2: printf("Please enter a valid date from 1 to 31: "); scanf("%d", &date); printf("How much do you want to withdraw? "); scanf("%f", &withdrw); if (withdrw > blnce) { printf("Please enter a smaller amt. \n"); printf("How much do you want to withdraw? "); scanf("%f", &withdrw); } else blnce2 = blnce - withdrw; printf("Your current balance is $%1.2f. \n", blnce2); dbt++; printf("Please indicate your option: "); scanf("%d", &opt); case 3: printf("Please enter a valid date from 1 to 31: "); scanf("%d", &date); printf("Your current balance is $%1.2f. \n", blnce); printf("Number of credit transactions: %d \n ", crdt); printf("Number of debit trasactions: %d \n ", dbt); printf("Please indicate your option: "); scanf("%d", &opt); case 4: printf("Statement of Account for October, 2004 \n"); printf("Number of credit transactions: %.2d \n ", crdt); printf("Number of debit transactions: %.2d \n ", dbt); intrst = blnce * yrly_intrst * 12; printf("Interest computed: $%1.2f \n", intrst); finalblnce = blnce + intrst; printf("Good Bye!! \n"); } return 0; }
are you a damn idiot?...you're the kind of person who would convert real player .ram files into mpeg's and wonder why they still sound so I am sillyI am sillyI am sillyI am sillyty.
No I am not an idiot... I am just more hardware than programming.. So this is not as easy as if I had to deal with servers, hubs, routers.. So sorry if it seems like I am an idiot.. But I am not and I don't appreciate being called one...
Hope this is better
Code:#include <stdio.h> #include <math.h> #define strt_blnce 2000.00 #define yrly_intrst .02 int main(int argc, char **argv) { float dpst, withdrw, withdrw2, blnce, crdt, dbt, intrst, finalblnce, blnce2; int date, opt; printf("Your current balance is $%1.2f \n", strt_blnce); printf("Banking program \n"); printf("1.) Deposit funds (credit transaction) \n"); printf("2.) Withdraw funds (debit transaction) \n"); printf("3.) Print statement of the acct \n"); printf("4.) Compute interest and exit program \n"); printf("Please indicate you option: "); scanf("%d", &opt); switch (opt) { case 1: crdt++; printf("Please enter a valid date from 1 to 31: "); scanf("%d", &date); printf("How much do you want to deposit? "); scanf("%f", &dpst); blnce = strt_blnce + dpst; printf("Your current balance is $%1.2f. \n", blnce); printf("Please indicate your option: "); scanf("%d", &opt); case 2: printf("Please enter a valid date from 1 to 31: "); scanf("%d", &date); printf("How much do you want to withdraw? "); scanf("%f", &withdrw); if (withdrw > blnce) { printf("Please enter a smaller amt. \n"); printf("How much do you want to withdraw? "); scanf("%f", &withdrw); } else blnce2 = blnce - withdrw; printf("Your current balance is $%1.2f. \n", blnce2); dbt++; printf("Please indicate your option: "); scanf("%d", &opt); case 3: printf("Please enter a valid date from 1 to 31: "); scanf("%d", &date); printf("Your current balance is $%1.2f. \n", blnce); printf("Number of credit transactions: %d \n ", crdt); printf("Number of debit trasactions: %d \n ", dbt); printf("Please indicate your option: "); scanf("%d", &opt); case 4: printf("Statement of Account for October, 2004 \n"); printf("Number of credit transactions: %.2d \n ", crdt); printf("Number of debit transactions: %.2d \n ", dbt); intrst = blnce * yrly_intrst * 12; printf("Interest computed: $%1.2f \n", intrst); finalblnce = blnce + intrst; printf("Good Bye!! \n"); } return 0; }
is that your entire program or did you cut it down?....it seems to me you need a loop....
This is the entire program
Why do the variables crdt and dbt need to be type float? When you use them to display your report, you are specifying an integer, and passing a type float value to printf(). Also, you might want to initialise crdt and dbt to zero before you use them. Do you really need to use the <math.h> header?
~/
Ya know I just saw this bank program in another thread. Must be a standard homework assignment somewhere.
What thread did you see a similar program on?
move printf accordingly after seeing output (ex: "Banking Program" should probably be outside of loop that i added)
Code:#include <stdio.h> #include <math.h> #define strt_blnce 2000.00 #define yrly_intrst .02 int main(int argc, char **argv) { float dpst, withdrw, withdrw2, blnce, crdt, dbt, intrst, finalblnce, blnce2; int date, opt = -1; //YOU SHOULD INDENT EVERYTHING INSIDE THIS LOOP //BUT I'M NOT GOING TO while(opt != 4){ printf("Your current balance is $%1.2f \n", strt_blnce); printf("Banking program \n"); printf("1.) Deposit funds (credit transaction) \n"); printf("2.) Withdraw funds (debit transaction) \n"); printf("3.) Print statement of the acct \n"); printf("4.) Compute interest and exit program \n"); printf("Please indicate you option: "); scanf("%d", &opt); switch (opt) { case 1: crdt++; printf("Please enter a valid date from 1 to 31: "); scanf("%d", &date); printf("How much do you want to deposit? "); scanf("%f", &dpst); blnce = strt_blnce + dpst; printf("Your current balance is $%1.2f. \n", blnce); printf("Please indicate your option: "); scanf("%d", &opt); case 2: printf("Please enter a valid date from 1 to 31: "); scanf("%d", &date); printf("How much do you want to withdraw? "); scanf("%f", &withdrw); if (withdrw > blnce) { printf("Please enter a smaller amt. \n"); printf("How much do you want to withdraw? "); scanf("%f", &withdrw); } else blnce2 = blnce - withdrw; printf("Your current balance is $%1.2f. \n", blnce2); dbt++; printf("Please indicate your option: "); scanf("%d", &opt); case 3: printf("Please enter a valid date from 1 to 31: "); scanf("%d", &date); printf("Your current balance is $%1.2f. \n", blnce); printf("Number of credit transactions: %d \n ", crdt); printf("Number of debit trasactions: %d \n ", dbt); printf("Please indicate your option: "); scanf("%d", &opt); case 4: printf("Statement of Account for October, 2004 \n"); printf("Number of credit transactions: %.2d \n ", crdt); printf("Number of debit transactions: %.2d \n ", dbt); intrst = blnce * yrly_intrst * 12; printf("Interest computed: $%1.2f \n", intrst); finalblnce = blnce + intrst; printf("Good Bye!! \n"); } }//END LOOP return 0; }
oh oh oh oh.....
make sure you dbt = 0 before using dbt++;....
if you don't do that dbt's value is the value of whatever was in that spot in memory before
make sure you initialize any variable you use for a counter...
saying
int count;
does not necessarily mean count will be zero
Last edited by misplaced; 10-07-2004 at 07:19 PM.