//Ian Forsyth #include<fstream.h> #include<iostream.h> #include<iomanip.h> #include<stdlib.h> struct inventory { char title[80]; char author[80]; double whole; double retail ; double tax; double cost; }; const int Index=100; int menu(); int doInput(); double doOutput(int checker, inventory thisOne[]); |
#include "filesTry2.h" int main() { cout<<"This is a Book program.\n"; menu(); return; } |
//Ian Forsyth #include "filesTry.h" int menu() { int choice=0; cout<<"What would you like to do?\n"; cout<<"\t1. Run\n"; cout<<"\t2. End\n"; cin>>choice; if(choice==2) { return(0); } doInput(); return(0); } int doInput() { int counter; int checker; char junk; struct inventory thisOne[Index]; cout<<"How many books are you stocking?\n"; cin>>checker; cin.get(junk); for(counter=0; counter<checker; counter++) { checker+ cout<<("Enter the book's title:\n"); cin.getline(thisOne[counter].title, 79); cout<<("Enter the book's author:\n"); cin.getline(thisOne[counter].author, 79); cout<<("Enter the item's whole sale cost:\n"); doOutput(checker, thisOne); cin>>thisOne[counter].whole; cout<<"Checker: "<<checker<<"\n"; cout<<"Counter: "<<counter<<"\n"; } doOutput(checker, thisOne); return(0); } double doOutput(int checker, inventory thisOne[]) { int counter; double allTax, allCost; for(counter=0; counter<checker; counter++) { thisOne[counter].retail=(thisOne[counter].whole*.65)+thisOne[counter].whole; thisOne[counter].tax=(thisOne[counter].retail*.65); thisOne[counter].cost=thisOne[counter].tax+thisOne[counter].retail; } for(counter=0; counter<checker; counter++) { cout.flags(ios::fixed); cout<<setprecision(2)<<"TITLE: "<<thisOne[counter].title<<"\n"; cout<<setprecision(2)<<"AUTHOR: "<<thisOne[counter].author<<"\n"; cout<<setprecision(2)<<"WHOLE: "<<thisOne[counter].whole<<"\n"; cout<<setprecision(2)<<"RETAIL: "<<thisOne[counter].retail<<"\n"; cout<<setprecision(2)<<"COST: "<<thisOne[counter].cost<<"\n"; } for(counter=0; counter<checker; counter++) { allCost+=thisOne[counter].cost; allTax+=thisOne[counter].tax; } cout<<setprecision(2)<<"\n\n\nTOTAL TAX: "<<allTax<<"\n"; cout<<setprecision(2)<<"TOTAL COST: "<<allCost<<"\n"; return(0); } |
checker+
and it's wrong