In this paper, we study an optimal maintenance model. The state of a system is determined by the distribution of its operating time. Whenever the system fails, a number of actions can be chosen, including the repair actions, the replacement actions and the action of discarding the system. The objective of this paper is to determine an optimal policy which maximizes the expected total discounted reward. By using the semi-Markov decision process approach, the method of successive approximations is suggested for determining the optimal reward function and the corresponding optimal policy.