Here's the problem and the solution that I could do. It has some LOGICAL errors. Can anyone please correct this program and make it work. Any help is greatly appreciated.

Problem: You dislike getting wet in the rain and you also hate carrying umbrellas. To this end, you keep a few umbrellas both at your home and in your office. If it is raining in the morning, you pick up an umbrella from your home and carry it to work. If it is raining in the evening, you pick up an umbrella from your office and carry it home. Note that if it is not raining when you step out of your home or your office, you do not carry an umbrella. You leave for work every morning and go home every evening.

Assume that if it is raining in the morning, it is raining all morning and if it is raining in the evening, it is raining all evening. Write a program called Umbrella.java that asks the user of the program for the probability of rain on any given morning or evening, number of umbrellas in the office, and the number of umbrellas at home. Your program should simulate this scenario a million times and print out the average number of days it takes before you end up getting wet in the rain because you step out of your home or office, find that it is raining but you have no umbrellas with you.

import java.util.Scanner;

public class Umbrella

{

public static void main ( String[] args )

{

Scanner input = new Scanner ( System.in );

int umbrellasAtHome = 0;

do

{

System.out.print ( "Enter the number of umbrellas at home: " );

umbrellasAtHome = input.nextInt();

} while ( umbrellasAtHome < 0 );

int umbrellasAtWork = 0;

do

{

System.out.print ( "Enter the number of umbrellas at work: " );

umbrellasAtWork = input.nextInt();

} while ( umbrellasAtWork < 0 );

double morningRain = 0;

do

{

System.out.print ( "Probability of rain in the morning: " );

morningRain = input.nextDouble();

} while ( ( morningRain < 0 ) || ( morningRain > 1.0 ) );

double eveningRain = 0;

do

{

System.out.print ( "Probability of rain in the evening: " );

eveningRain = input.nextDouble();

} while ( ( eveningRain < 0 ) || ( eveningRain > 1.0 ) );

double forgetfulness = 0;

long cumulativeDaysSum = 0;

if ( ( morningRain == 0 ) &&

( eveningRain == 0 )

)

{

System.out.println ( "It will never rain!" );

return;

}

for ( int exp = 0; exp < 1000; exp++)

{

cumulativeDaysSum += Experiment ( umbrellasAtHome,

umbrellasAtWork,

morningRain,

eveningRain,

forgetfulness

);

}

System.out.printf ( "I will get wet every %.2f days\n",

cumulativeDaysSum/1000.0 );

}

public static int Experiment ( int umbrellasAtHome,

int umbrellasAtWork,

double morningRain,

double eveningRain,

double forgetfulness

)

{

boolean gotWet = false;

int numberDaysElapsed = 0;

while ( !gotWet )

{

numberDaysElapsed++;

if ( Math.random() < morningRain )

{

if ( umbrellasAtHome == 0 )

{

gotWet = true;

break;

}

umbrellasAtHome--;

if ( Math.random() < forgetfulness )

{

gotWet = true;

break;

}

umbrellasAtWork++;

}

if ( Math.random() < eveningRain )

{

if ( umbrellasAtWork == 0)

{

gotWet = true;

break;

}

umbrellasAtWork--;

if ( Math.random() < forgetfulness )

{

gotWet = true;

break;

}

umbrellasAtHome++;

}

}

return numberDaysElapsed;

}

}