I need help with this program.

The Greedy Ringy Manufacturing Company makes a common household item called a doflingy. The Greedy Ringy Doflingy shipping clerk is faced with the following problem: Doflingies are very delicate and must be shipped in special, very expensive, containers. These containers are available in 4 sizes: huge, large, medium, and small, which can hold, respectively, 50, 20, 5, and 1 doflingies.

Write a program that prompts a user for their name, address, and the number of doflingies ordered and displays their shipping information along with the number of huge, large, medium, and small containers needed to send the shipment in the minimum number of containers and with the minimum amount of wasted container space.

So far I have:

#include <iostream>
using namespace std;
int main ()

{
int name, city, address, state, zipCode;



cout << "Enter the name of the purchaser:\n";
cin >> name;
cout << "Enter the street address:\n";
cin >> city;
cout << "Enter city:\n";
cin >> address;
cout << "Enter state:\n";
cin >> state;
cout << "Enter zipcode:\n";
cin >> zipCode;
}

A little direction is all I need. I want to program to ask me a sequence of questions right now its just asking one question and I give it a answer and it runs through the rest.
Your "name" variable is an int. Change it to string and everything will work.
I prefer using endl instead of '\n' when a newline is need. For example, cout << "Enter the name of the purchaser:" << endl;
Thank you Paa the string declaration worked.

Quan I go in between the two but I understand what you are saying.
What do I do if my program is falling through questions?
Did you try to enter text information into int variable again?

DId yo try to enter name lke "John Smith" (with whitespace)?
I entered text information into my name variable which is delcared as a string. It works if I do "JohnSmith" but "John Smith" falls through.

So this is what I did to compensate.



#include <iostream>
using namespace std;
int main ()

{
string firstN, lastN, streetNum, streetName,streetSuffix, city, state1;
int zipCode;
int huge = 50;
int large = 20;
int medium = 5;
int small = 1;
int totDoflingies;



cout << "Enter name of the purchaser:";
cin >> firstN;
cin >> lastN;
cout << "Enter the street address:";

cin >> streetNum;
cin >> streetName;
cin >> streetSuffix;

cout << "Enter city:";
cin >> city;


cout << "Enter state:(Use abbreviation XX)";
cin >> state1;



cout << "Enter zipcode:";
cin >> zipCode;

cout << " \n";

cout << "Ship To: " << firstN << " " << lastN << endl;
cout << " " << streetNum << " " << streetName << " "<< streetSuffix << endl;
cout << " " <<city << " " << state1 << " " << zipCode << endl;

cout << " \n";

cout << "Enter the number of doflingies ordered:";
cin >> totDoflingies;

cout << " \n";

cout << "No. Doflingies: " << totDoflingies;

cout << " \n";

cout << "Container Size Number Required\n";
cout << "--------------- ----------------\n";
cout << "Huge \n";
cout << "Large \n";
cout << "Medium \n";
cout << "Small ";


Well it should be expected. Operator>> takes values separated by whitespace characters. So if you enter "John Smith" first cin>> will get "John" and second - "Smith"
Topic archived. No new replies allowed.