Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Mailing Labels - Breaking into two columns on output file layout (http://www.go4expert.com/forums/mailing-labels-breaking-columns-output-t7247/)

Prosdo 11Nov2007 04:16

Mailing Labels - Breaking into two columns on output file layout
 
Hi everyone. I am very new to C++ and taking a class. I have a program due on Monday and I ran into a wall. The programs calls for us to make mailing labels. They must be in this format:

Michael Smith
555 Lincoln Way
Philadelphia, PA 24211
Box 1 of 5

The odd labels must be on the left and the even on the right they should be sent to the output file in the layout

LABEL1 LABEL 2
LABEL 3 LABEL 4
LABEL 5

So I need them to enter the number of boxes and it should count up to the number they need. I figured for that I would need something like number = number + 1. We can use loops, but I am not to sure with those. Here is the code I have so far:

Quote:

#include <iostream.h>
#include <stdlib.h>
#include <cstring>
#include <string>
#include <fstream>

using namespace std;
string name; // Is the name for the mailing labels
string address; // Is the address for the mailing labels
string zip; // Is the zipcode for the mailing labels
string state; // Is the state for the mailing labels
string city; // Is the city for the mailing labels
int number_of_boxes; // Number of labels neeeded
int number; //Current Label
ofstream mailing_labels;

int main()
{
mailing_labels.open("D:\\mailing_labels.dat");

cout <<"Please enter the name of the person you are shipping these items to: " <<'\n'; //Asks for the name
cin >> name; //Accepts the name
cout <<"Please enter the street address you are shipping to: "<<'\n'; //Asks for the street address
cin >> address; //Accepts the street address
cout <<"Please enter the city you are shipping to: "<<'\n'; //Asks for the city
cin >> city; //Accepts the city
cout <<"Please enter the two letter abbreviation of the state you are shipping to: "<<'\n'; //Asks for the state
cin >> state; //Accepts the state
cout <<"Please enter the zip code you are shipping to: "<<'\n'; //Asks for the zip code
cin >> zip; //Accepts the zip code
cout <<"How many boxes are you shipping? "<<'\n'; //Asks for number of boxes
cin >> number_of_boxes; //Accepts number of boxes



system("PAUSE");
return 0;
}
My teacher said I would need the modulus operator to split the sides of the mailing list? Can anyone help? Also do I need to use a loop for this? Thanks guys


All times are GMT +5.5. The time now is 12:05.