#include <iostream>
struct Customer
{
std::string name;
std::string address;
std::string citystatezipcode;
std::string telephone_number;
double account_balance;
std::string last_payment;
};
void mainMenu()
{
std::cout << "1. Enter New Account Information\n";
std::cout << "2. Change Account Information\n";
std::cout << "3. Display All Account Information\n";
std::cout << "4. Exit The Program\n";
std::cout << "\n";
}
Customer new_Info()
{
Customer new_Customer;
std::cout <<"New Customer" << std::endl;
std::cout <<"Name: ";
std::getline(std::cin, new_Customer.name);
while(new_Customer.name.empty())
{
std::cout <<"Please Enter A Name!: ";
std::getline(std::cin,new_Customer.name);
}
std::cout <<"Address: ";
std::getline(std::cin, new_Customer.address);
while(new_Customer.address.empty())
{
std::cout <<"Please Enter A Address!: ";
std::getline(std::cin,new_Customer.address);
}
std::cout << "Please Enter City,State,Zipcode: ";
std::getline(std::cin,new_Customer.citystatezipcode);
while(new_Customer.citystatezipcode.empty())
{
std::cout <<"Please Enter A City,State,Zipcode: ";
std::getline(std::cin, new_Customer.citystatezipcode);
}
std::cout <<"Please Enter A Telephone Number EX: 936-201-2010: ";
std::getline(std::cin,new_Customer.telephone_number);
while(new_Customer.telephone_number.length() != 12)
{
std::cout <<"Please Re-Enter Your Telephone Number: ";
std::getline(std::cin,new_Customer.telephone_number);
}
std::cout <<"Enter Account Balance: ";
std::cin >> new_Customer.account_balance;
while(new_Customer.account_balance < 0)
{
std::cout <<"Please Re-Enter A Positive Balance: ";
std::cin >> new_Customer.account_balance;
}
std::cout << "Please Enter Date Of Last Payment EX: 01/01/2020: ";
std::getline(std::cin,new_Customer.last_payment);
while(new_Customer.last_payment.length() != 10)
{
std::cout <<"Please Re-Enter Date of Last Payment EX: 01/01/2020: ";
std::getline(std::cin,new_Customer.last_payment);
}
return new_Customer;
}
int main() {
mainMenu();
new_Info();
}
When I enter the info everything is good until after I get to the last payment question, after that the program is supposed to give you the question "Please Enter Date of Last Payment: " but then it also c-outs the while loop "Please Re-Enter Date Of Your Last Payment" for some reason even though I haven't answered the first question.