0
#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.

  • Can you give us a full transcript of a program run with all of your inputs/outpus? – scohe001 Nov 04 '20 at 17:18
  • @scohe001 Wait what do you mean by that? You can just copy and paste my code and see what the issue is if you would like. –  Nov 04 '20 at 17:20
  • Not without knowing what you're entering to reproduce the issue...it could be something with the data you're entering (and in fact it is. It's your newlines that you're ending input values with, it looks like) – scohe001 Nov 04 '20 at 17:22
  • @scohe001 yeah its because for the strings I don't want it to be get messed up if its like an address that has a space you know. For Instance If I type in the address 3720 College Spring Dr., it would result in an error because I didn't use the get line method. –  Nov 04 '20 at 20:31

0 Answers0