the way i would make this program is like this
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
float password;
string number,Nameone = "steve", Nametwo = "betty", loop;
cout<<"This is my phone book continue looking up numbers?(yes or no): ";
cin>>loop;
cin.ignore();
cout<<"\nEnter the password: ";
cin>>password;
cin.ignore();
while (loop == "yes")
{
if (password == 1337) {
cout<<"\nWhat number are you requesting?\n";
cin>>number;
cin.ignore();
}
if (number == Nameone)
cout<<"\nThe number is 544-6789";
else
if (number == Nametwo)
cout<<"\nThe number is 456-4566";
cout<<"\nwould you like to find another number?(yes or no):";
cin>>loop;
cin.ignore();
}
return 0;
}
any questions?
#include <string> makes it so they can type names instead of just one letter or number, i think that is why your program was closing also set Nameone to = "steve" (i just made up a random name) since "steve" is a string the program will recognize it, i hope that isn't confusing i also added it so it would loop so the program wont close after finding only one number
whoohoo i finally helped someone and wasn't asking for help myself this is a big acheivement for me lol i hope this helped you