I made a script that is suppose to be a customer order form. It works at the start but for some reason it will not let me type in my name.
It goes straight to the phone number and address. It will skip cout << "Please Enter Your Name: \n";.What is wrong with my code? Thank you in advance.
I am using codeblocks.
This is what I got.
#include <iostream>
using namespace std;
int main()
{
int choice;
bool menuOn = true;
while (menuOn != false){
cout << "*******************************\n";
cout << " 1 - Input Customer Information .\n";
cout << " 2 - Main Selection\n";
cout << " 3 - Options\n";
cout << " 4 - credit card information\n";
cout << " 5 - Display Order Confirmation\n";
cout << " 6 - Exit.\n";
cout << " Enter your choice and press return: ";
cout << "Please Enter Your Name: \n";
cin.getline(name, 20);
cout << "Please Enter Your phone number: \n";
cin.getline(number, 20);
cout << "Enter your Address: \n";
cin.getline(address, 40);
cout << "' Your name is: '" << name << "' And your phone number is: '" << number << "' And your address is: '" << address << "'";
cin.get();
break;
case 2:
cout << " Main selection\n";
// rest of code here
break;
case 3:
cout << "options\n";
// rest of code here
break;
case 4:
char visa[20];
char mastercard[20];
char cash[40];
cout << "Please Enter Your visa information: \n";
cin.getline(visa, 20);
cout << "Please Enter Your mastercard: \n";
cin.getline(mastercard, 20);
cout << "Enter cash: \n";
cin.getline(cash, 40);
cout << "Your visa is: '" << visa << "' And your Mastercard is: '" << mastercard << "' And cash entered: '" << cash << "'";
cin.get();
// rest of code here
break;
case 5:
cout << " Display Order Confirmation\n";
// rest of code here
break;
case 6:
cout << "End of Program.\n";
menuOn = false;
break;
default:
cout << "Not a Valid Choice. \n";
cout << "Choose again.\n";
cin >> choice;
break;
}
}
return 0;
}
Problem: Under Input customer information. Enter 1
Please Enter Your Name: will not let me input name??
Please Enter Your phone number:9999999999