can you please write this program in java ?