When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
97 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
Please help , why its not working ?
you need to have qualifiers for functions from the standard library
so cout should be std::cout
and so on
naa dont use libray its a requiremnt
if the customer have already rented a car and want to rent another car so i wanted him to buy a car not give his imformation again , i need this to happen
cout, string, cin are from the standard library that comes with c++
oh yeah i know
the logic is not working
alright, so you have using namespace std; somewhere?
yes yes bruh
if the customer have already rented a car and want to rent another car so i wanted him to buy a car not give his imformation again , i need this to happen
have you tried debugging?
so uuh, could you post the context code?
because from the code you posted it looks like you're comparing entered_name == registered_name when registered name is empty
string registered_name=""; will make registered_name empty every time you go through that line
oh then what should i do
you should specify what you want the program to do more exactly
like is this code meant to just be in main()?
or in a loop
you find something ?
what's the expected output and what's the actual output
and what user input are you giving
expected output is that if the user first registered himself he has not to registerd again to rent a car
Does the check apply to a program restart?
what check ?
Checking if the user is registered
how to do that i dont understand
Do you want to store registered users later so that when the program is ran again, it doesn't forget them?
yeah yeah
So you want the program to remember who's registered after it's ended (terminated)
and when you run it again?
Wanna be sure
yeah for sure
Then you have three options
I wouldn't recommend 3 for small projects
Scrap the "remember users when you exit"
it's pretty much that
well tbh i dont wanna store his all imformation just if he has registered one time 2 time he will not registered
i dint mean to exist the whole program
You don't need to store all their info
Just a name/last name works
Alright then it's entirely different
so yeah there is a menu if the user wants to rent a car he has to registered and if he wants to rent another car he will get it without registering again
use a std::vector<std::string>
store First name + Last name
on new user register check if First name + Last name already exists in the vector
Tho I'd suggest a more robust way like this
i dont use vector
struct Customer {
std::string first_name;
std::string last_name;
int ssn;
};
Do you know how many there are?
Do you know what a struct is?
yeah yeah
Well yeah just do this too
struct customer {
std::string first_name;
std::string last_name;
int ssn;
bool operator == (customer& other) {
return ssn == other.ssn;
}
};
ssn is always unique
first name + last name isn't
Up to you
ok then ?
on each input, check if this array of customer (or std::string if you wanna) already has this value or not
if it doesn't
then just add it to the array
heads up, you can't increase an array size
make sure you use a reasonable number
its pretty hard tho
i have done this with rent car and avalible cars but there i use bool isrented like this
It's not
You just loop through the array elements
And check if element is equal to first name given to you
void rentCar(int id)
{
node *temp = head;
while (temp != NULL)
{
if (temp->carid == id)
{
if (temp->isRented)
{
cout << "Car is already rented" << endl;
return;
}
else
{
temp->isRented = true;
string name, mobileno;
bool isregis = false;
if (!isregis)
{
cout << "ENter your name : ";
cin >> name;
cout << "Enter your phoneno : ";
cin >> mobileno;
}
else
{
// isregis = true;
cout << "You are already registerd member";
// return;
}
cout << "Car rented successfully" << endl;
total_cars--;
return;
}
}
temp = temp->next;
}
cout << "Invalid car ID" << endl;
}
```cpp
are you using a linked list?
ok how ?
@hallow notch Has your question been resolved? If so, run !solved :)
Thank you and let us know if you have any more questions!