The user who has not yet purchased any item should get the discount and if the user visits for the second time then the discount should not be given.
Loading
The user who has not yet purchased any item should get the discount and if the user visits for the second time then the discount should not be given.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhishek ChadhaPosted May 28, 2024, 6:55 PM
1. Initialize a variable to track the number of purchases made by the user.
2. Prompt the user if they have made any purchases before.
3. If the user has not made any purchases:
- Grant the discount.
- Increment the purchase count.
4. If the user has made purchases before:
- Check if it's the user's second visit.
- If it's the user's second visit:
- Do not grant the discount.
- If it's not the user's second visit:
- Do not grant the discount again.
5. End.
Tuhin PaulPosted May 31, 2024, 2:26 AM
here the
Userclass encapsulates the behavior of a user, and theVisitStoremethod simulates the user visiting the store.