If it is a notebook computer: 50% probability four years. 25% five years. 10% six years. If it is a desktop computer, life is a lot longer. You can expect a minimum of five years, eight years is not uncommon and 10 years is possible. About 7 years is what you should plan on.
Most likely you will replace your desktop not because it breaks, but because you are getting tired of waiting for it. Then you will buy one that is at least twice as fast.
Another leading cause for replacement is infection and corruption. If you take your computer to a computer store to fix this kind of problem, it will not be cheap. However, it is quite likely that your computer has a copy of what was on the hard drive when you first turned it on when you brought it home. It is called the Factory Restore. You will need to find out how to access this hidden partition, but when you do, you can erase your hard drive and restore the original content. Of course, your data and the programs you have added will be lost, but if you have backed up, you will at least be able to restore it. If you do this, you are very likely to be very pleased with the result. Your computer will run like new.
You can extend a desktop computer’s life when it gets too slow by investing in improvements at around 3 or 4 years and more importantly by buying the right configuration in the beginning. Computers are not all the same. What’s inside can make big differences, even with similar prices. This can be complicated but can make a big difference.
Ask for my help and I can offer you suggestions on how to optimize your spending. Those guys at the electronics shops like xxxxxBuy sell machines that maximize their profit. They are not configured, nor are they incented to give you the best value for your money. Use a company that allows you to configure what works best for you and gives you best value. Generally speaking, it is best to buy more power than you think you need. Don’t buy the most expensive. The next most expensive is usually the best buy. Get knowledgeable, unbiased help to do this.