| | |
homework help
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2009
Posts: 7
Reputation:
Solved Threads: 0
This is part of some class work I have to do, but this is not what I am turning in as my assignment! It does have some bugs, but as long as the user only enters an integer it runs fine.
I have included just the part of the code that I need help with. It compiles and runs through the program, but does do what I want it do.
I have 2 questions, one is how do I get the CR entered to save to the account? And the second is, once it is stored, how do I display that information? More details are in block comments in the code. I hope my question is clear.
I have included just the part of the code that I need help with. It compiles and runs through the program, but does do what I want it do.
I have 2 questions, one is how do I get the CR entered to save to the account? And the second is, once it is stored, how do I display that information? More details are in block comments in the code. I hope my question is clear.
C Syntax (Toggle Plain Text)
/*Current Problems which need to be fixed: Input account number and be able to change the account balance accordingly. When prompted, display the account balance accordingly. */ #include <stdio.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #define DAY 2 #define MAXACCT 25 int main(void) { printf("Basic Accounting Program\n\n"); int acct; int count, factorial; int choice = 0; long credit; int debit = 0; int j = 0; int bal; /*these are declared from another program, using them as aides in understanding*/ long balance[MAXACCT]; long jacct[MAXACCT]; int thisacct; int thisamt; int i; int foundacnt; char input[25]; char rtrn; /*end of items declared from other program*/ for (count = 1; count < DAY ; count++) { printf ("Day %d\n\n",count); here1: printf ("Input account number, thank you!\n"); rtrn = scanf ("%d", &jacct); here: printf ("\nPlease choose an option below\n"); printf ("\t1. Credit (Charge Card Transaction: CR)\n"); printf ("\t5. Account Balance\n"); printf ("\t8. Exit\n"); printf ("Please enter your choice: \n"); scanf ("%d", &choice); if (choice == 1) { printf ("Input CR\n"); scanf ("%d", &credit); /*how do i get the credit (money added) to be applied to the account? for example, suppose I choose option 1 two times, how do I make the first CR add to the 2nd CR?*/ bal = 0 + credit; goto here; } else if (choice == 5) { printf ("Your account balance is %d\n", bal); /*how do i save and output the adjusted balance? for example, suppose I entered two CR (option 1) transactions, the first time I CR the account 5, then 10, so now I want the balance to say 15.*/ goto here; } else if (choice == 8) { return (0); } else if (choice != 1 || choice != 5 || choice != 8) { printf ("OOPS! Invalid Entry!\n"); goto here; } here2: ; } return 1; }
![]() |
Similar Threads
- We only give homework help to those who show effort (Computer Science)
- Need help with Computer Science homework (Computer Science)
- I am having homework isues. Please Help (Java)
- Homework Help!! Priority Queue ?? (Computer Science)
Other Threads in the C Forum
- Previous Thread: adding a character to a string
- Next Thread: Help about my program. About files
| Thread Tools | Search this Thread |
Tag cloud for C
#include * append array arrays asterisks binarysearch calculate changingto char character cm command copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic execv feet fgets file fork forloop framework function functions givemetehcodez grade graphics gtkwinlinux hacking histogram homework include incrementoperators input intmain() iso kernel keyboard km lazy license linked linkedlist linux list lists locate logical_drives looping loopinsideloop. lowest matrix microsoft motherboard mqqueue number oddnumber odf opensource overwrite owf pdf performance pointer posix problem probleminc process program programming radix recursion recv recvblocked research reversing scanf scripting segmentationfault sequential socket socketprograming spoonfeeding standard string student systemcall testing threads turboc unix user variable wab whythiscodecausesegmentationfault windowsapi






