|
Hi everyone. I am very new to C++ and taking a class. (don't laugh too hard at me lol) 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:
#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 box_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 I wanted to use a for loop, but I am kind of confused on how to format it? Thanks guys. Any help would be SO greatly appreciated.
Edit/Delete Message
|
|
|
|
|
|
|
// |