Yes it helped a little bit, but I'm still confused as to how to have the info input into the file.
This is what I've now added to it. But my question is, do I have to prompt the user to re-input all the information for a new package, address, ect for each package they want to add to the file?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
case multiMail:
ofstream outputFile; //File stream object.
//Get number of items being sent.
cout<<"How many seperate items are you sending today?";
cin>>numberOfMailings
//Open the given file.
outputFile.open("Mailings.txt");
//Get the info for each item being mailed and write it to the file.
for (int count=2; count<=numberOfMailings; count++)
{
cout<<"Enter the mailing info for address"<<count<<": ";
}
|
So do I now prompt the user to do this now?:
cout<<"Please enter your name:";
getline(cin, name);
cout<<"Please enter your street address:";
getline(cin, streetAddress);
cout<<"Please enter your city:";
getline(cin, city);
cout<<"Please enter your state:";
getline(cin, state);
cout<<"Please enter your zipcode:";
cin>>zipcode;
cout<<"Please enter 1 for letter, 2 for envelope or 3 for parcel:";
cin>>number;
cout<<"Please enter item's weight in ounces:";
cin>>weight;
//Calculate the cost of the item based off of type and weight.
if (number==1&&weight<=1)
cout<<"******************************"<<cost1<<"\n\n";
else if (number==1&&weight>1)
cout<<"******************************"<<cost1+(weight*addCharge1)<<"\n\n";
else if (number==2&&weight<=1)
cout<<"******************************"<<cost2<<"\n\n";
else if (number==2&&weight>1)
cout<<"******************************"<<cost2+(weight*addCharge1)<<"\n\n";
else if (number==3&&weight<=3)
cout<<"******************************"<<cost3<<"\n\n";
else if (number==3&&weight>3)
cout<<"******************************"<<cost3+(weight*addCharge2)<<"\n\n";
else
cout<<"Invalid input, restart program."<<endl;
//The following will output the address information based off the user input.
cout<<name<<endl;
cout<<streetAddress<<endl;
cout<<city<<", "<<state<<" "<<zipcode<<"\n\n";
//The following converts the user input zipcode into a barcode.
string result;
char digit;
int checkSum;
{
if (digit == '0')
result= "||:::";
else if (digit == '1')
result= ":::||";
else if (digit == '2')
result= "::|:|";
else if (digit == '3')
result= "::||:";
else if (digit == '4')
result= ":|::|";
else if (digit == '5')
result= ":|:|:";
else if (digit == '6')
result= ":||::";
else if (digit == '7')
result= "|:::|";
else if (digit == '8')
result= "|:::|";
else if (digit == '9')
result= "|:|::";
else
result= "Invalid";
}
result=zipcode;
checkSum=(zipcode%10)
cout<<"| "<<zipcode<<checkSum<<" |"; //Displays barcode.
I feel like there's something big I'm missing but again, I'm very new to this and to be honest, my professor has kinda left me on my own, providing little to know pointers. So I'm pretty much forced to figure this stuff out on my own, but I have a due date. This wouldn't be hard if I didn't work a job and have other classes, I just simply don't have time to fool around for hours on end and figure it out myself. This is all part of my big delima XD