Ok so this is my code below in my member function definition .cpp file. The problem is when I execute the program it will not let me fill the answer for the first question so for example the output is:
Please enter the name of the receiver: Please enter the address of the receiver:
Please enter the city of the receiver:
Please enter the state of the receiver:
Please enter the zip code of the receiver:
and yada yada....
It completely skips the first one but will let me answer the rest of the questions and program continues to work as deisgned. Did I make a mistake somewhere where I used my strings or getline functions?
//Package class member-function definitions
#include <iostream>
using namespace std;
#include "package.h"
Package::Package(double weight, double cost)//constructor
{
setWeight(weight);
setCost(cost);
}
void Package::setSenderName()//set name
{
cout << "Please enter the name of the sender: " << endl;
getline(cin, sName);
}
string Package::getSenderName() const//return name
{
return sName;
}
void Package::setSenderAddress()//set address
{
cout << "Please enter the address of the sender: " << endl;
getline(cin, sAddress);
}
string Package::getSenderAddress() const//return address
{
return sAddress;
}
void Package::setSenderCity()//set city
{
cout << "Please enter the city of the sender: " << endl;
getline(cin, sCity);
}
string Package::getSenderCity() const//return city
{
return sCity;
}
void Package::setSenderState()//set state
{
cout << "Please enter the state of the sender: " << endl;
getline(cin, sState);
}
string Package::getSenderState() const//return state
{
return sState;
}
void Package::setSenderZipCode()//set zip code
{
cout << "Please enter the zip code of the sender: " << endl;
getline(cin, sCode);
}
string Package::getSenderZipCode() const//return zip code
{
return sCode;
}
/***********************************************************************************************/
void Package::setReceiverName()//set name
{
cout << "Please enter the name of the receiver: " << endl;
getline(cin, rName);
}
string Package::getReceiverName() const//return name
{
return rName;
}
void Package::setReceiverAddress()//set address
{
cout << "Please enter the address of the receiver: " << endl;
getline(cin, rAddress);
}
string Package::getReceiverAddress() const//return address
{
return rAddress;
}
void Package::setReceiverCity()//set city
{
cout << "Please enter the city of the receiver: " << endl;
getline(cin, rCity);
}
string Package::getReceiverCity() const//return city
{
return rCity;
}
void Package::setReceiverState()//set state
{
cout << "Please enter the state of the receiver: " << endl;
getline(cin, rState);
}
string Package::getReceiverState() const//return state
{
return rState;
}
void Package::setReceiverZipCode()//set zip code
{
cout << "Please enter the zip code of the receiver: " << endl;
getline(cin, rCode);
}
string Package::getReceiverZipCode() const//return zip code
{
return rCode;
}
/**********************************************************************************************/
void Package::setWeight(double pweight)//set weight
{
if(pweight < 0.0)
{
weight = 0.0;
} else
{
weight = pweight;
}
}
double Package::getWeight() const//return weight
{
return weight;
}
void Package::setCost(double pcost)//set cost
{
if(pcost < 0.0)
{
cost = 0.0;
} else
{
cost = pcost;
}
}
double Package::getCost() const//return cost
{
return cost;
}
double Package::calculateCost() const//calculates cost of sending a package
{
return weight * cost;
}
void Package::setInfo()
{
setSenderName();
setSenderAddress();
setSenderCity();
setSenderState();
setSenderZipCode();
/*******/
setReceiverName();
setReceiverAddress();
setReceiverCity();
setReceiverState();
setReceiverZipCode();
}
void Package::print()//sender and receiver information
{
setInfo();
cout << "Sender's Information: \n";
cout << sName << ' ' << "\n" << sAddress
<< "\n" << sCity << ", " << sState << ' ' << sCode << endl;
cout << "\nReceiver's Information: \n";
cout << rName << ' ' << "\n" << rAddress
<< "\n" << rCity << ", " << rState << ' ' << rCode << endl;