Develop an application that an electric company may used to produce monthly bill
ID: 3638473 • Letter: D
Question
Develop an application that an electric company may used to produce monthly bills for its customers. A monthly bill for a customer is to be formatted as follows:Create a program that it "prints" out this screen:
B I L L
We Power U Electric Co-Operative Date: 02/12/2012
To: John Jones Account: 389403020
99 Main Street
Bigtown, PA 15800
Meter Readings:
Start Meter Reading: 1231.2 KW read on 01/10/2012
End Meter Reading: 1874.9 KW read on 02/10/2012
Total KW Used: 643.7 KW
Bill Computation:
Previous Amounts (past due) $ 0.00
Cost of KW Used 643.7 X 0.132 per KW $ 84.97
Federal Tax at 12% $ 10.20
Total Due (date due 03/03/2012) $ 95.17
Discount Amount(10% if paid by 02/22/2012) $ 86.67
Explanation / Answer
#include #include #include #include #include int main(int argc, char *argv[]) // Reads { char char_read; int fd; if (argc < 2) { fprintf(stderr, "readfile: Filename must be specified "); exit(EXIT_FAILURE); } if ((fd = open(argv[1], O_RDONLY)) < 0) { perror(argv[1]); exit(EXIT_FAILURE); } while(read(fd, &char_read, 1) > 0) printf("%c", char_read); exit(EXIT_SUCCESS); } // fgetc() char char_read; FILE *fileptr; if (argc < 2) { fprintf(stderr, "readfile: Filename must be specified "); exit(EXIT_FAILURE); } if ((fileptr = fopen(argv[1], "r")) == NULL) { perror(argv[1]); exit(EXIT_FAILURE); } while((char_read = fgetc(fileptr)) != EOF) printf("%c", char_read); exit(EXIT_SUCCESS); } char mode[] = ""; char buf[] = ""; int i; i = strtol(mode, 0, 8); if (chmod (buf,i) < 0) { fprint(stderr, "%s: error in chmod(%s, %s) - %d (%s) ", argv[0], buf, mode, errno, strerror(errno)); exit(1); } return(0); }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.