RainfallTest.java
import java.util.Arrays;
import java.util.Scanner;
public class RainfallTest {
/**
* @param args
*/
static String month[] = {\"January\", \"Fabruary\", \"March\", \"April\", \"May\", \"June\",
\"July\", \"August\", \"September\",\"October\",\"November\",\"December\"};
public static void main(String[] args) {
// TODO Auto-generated method stub
int months[] = new int[12];
Scanner scan = new Scanner(System.in);
for(int i=0; i months[i]){
min = months[i];
minIndex = i;
}
}
System.out.println(\"The minimum rainfall is :\"+min);
System.out.println(\"The minimum rainfall month is :\"+month[minIndex]);
}
public static void updaeRainFallForMonth(int months[]){
Scanner scan = new Scanner(System.in);
System.out.println(\"Enter a month (1-12) for rainfall update:\");
int month = scan.nextInt();
System.out.println(\"Enter rainfall for update:\");
int rainfall = scan.nextInt();
months[month-1] = rainfall;
}
public static void exit(){
System.exit(0);
}
}
Output:
Enter Rainfall for the month 1:
55
Enter Rainfall for the month 2:
66
Enter Rainfall for the month 3:
77
Enter Rainfall for the month 4:
44
Enter Rainfall for the month 5:
33
Enter Rainfall for the month 6:
22
Enter Rainfall for the month 7:
11
Enter Rainfall for the month 8:
99
Enter Rainfall for the month 9:
88
Enter Rainfall for the month 10:
45
Enter Rainfall for the month 11:
56
Enter Rainfall for the month 12:
67
Entered rainfall details [55, 66, 77, 44, 33, 22, 11, 99, 88, 45, 56, 67]
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
1
January: 55
Fabruary: 66
March: 77
April: 44
May: 33
June: 22
July: 11
August: 99
September: 88
October: 45
November: 56
December: 67
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
2
The total rainfall is :663
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
3
The average rainfall is :55.25
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
4
The maximum rainfall is :99
The maximum rainfall month is :August
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rai.
1. RainfallTest.java
import java.util.Arrays;
import java.util.Scanner;
public class RainfallTest {
/**
* @param args
*/
static String month[] = {"January", "Fabruary", "March", "April", "May", "June",
"July", "August", "September","October","November","December"};
public static void main(String[] args) {
// TODO Auto-generated method stub
int months[] = new int[12];
Scanner scan = new Scanner(System.in);
for(int i=0; i months[i]){
min = months[i];
minIndex = i;
}
}
System.out.println("The minimum rainfall is :"+min);
System.out.println("The minimum rainfall month is :"+month[minIndex]);
}
public static void updaeRainFallForMonth(int months[]){
Scanner scan = new Scanner(System.in);
System.out.println("Enter a month (1-12) for rainfall update:");
int month = scan.nextInt();
System.out.println("Enter rainfall for update:");
int rainfall = scan.nextInt();
months[month-1] = rainfall;
}
public static void exit(){
System.exit(0);
}
}
2. Output:
Enter Rainfall for the month 1:
55
Enter Rainfall for the month 2:
66
Enter Rainfall for the month 3:
77
Enter Rainfall for the month 4:
44
Enter Rainfall for the month 5:
33
Enter Rainfall for the month 6:
22
Enter Rainfall for the month 7:
11
Enter Rainfall for the month 8:
99
Enter Rainfall for the month 9:
88
Enter Rainfall for the month 10:
45
Enter Rainfall for the month 11:
56
Enter Rainfall for the month 12:
67
Entered rainfall details [55, 66, 77, 44, 33, 22, 11, 99, 88, 45, 56, 67]
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
1
January: 55
3. Fabruary: 66
March: 77
April: 44
May: 33
June: 22
July: 11
August: 99
September: 88
October: 45
November: 56
December: 67
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
2
The total rainfall is :663
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
3
The average rainfall is :55.25
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
4. .5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
4
The maximum rainfall is :99
The maximum rainfall month is :August
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
5
The minimum rainfall is :11
The minimum rainfall month is :July
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
6
Enter a month (1-12) for rainfall update:
7
Enter rainfall for update:
99
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
5. 6.update the amount of rain in any given month
7.quit
4
The maximum rainfall is :99
The maximum rainfall month is :July
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
7
Solution
RainfallTest.java
import java.util.Arrays;
import java.util.Scanner;
public class RainfallTest {
/**
* @param args
*/
static String month[] = {"January", "Fabruary", "March", "April", "May", "June",
"July", "August", "September","October","November","December"};
public static void main(String[] args) {
// TODO Auto-generated method stub
int months[] = new int[12];
Scanner scan = new Scanner(System.in);
for(int i=0; i months[i]){
min = months[i];
minIndex = i;
}
6. }
System.out.println("The minimum rainfall is :"+min);
System.out.println("The minimum rainfall month is :"+month[minIndex]);
}
public static void updaeRainFallForMonth(int months[]){
Scanner scan = new Scanner(System.in);
System.out.println("Enter a month (1-12) for rainfall update:");
int month = scan.nextInt();
System.out.println("Enter rainfall for update:");
int rainfall = scan.nextInt();
months[month-1] = rainfall;
}
public static void exit(){
System.exit(0);
}
}
Output:
Enter Rainfall for the month 1:
55
Enter Rainfall for the month 2:
66
Enter Rainfall for the month 3:
77
Enter Rainfall for the month 4:
44
Enter Rainfall for the month 5:
33
Enter Rainfall for the month 6:
22
Enter Rainfall for the month 7:
11
Enter Rainfall for the month 8:
99
Enter Rainfall for the month 9:
88
Enter Rainfall for the month 10:
7. 45
Enter Rainfall for the month 11:
56
Enter Rainfall for the month 12:
67
Entered rainfall details [55, 66, 77, 44, 33, 22, 11, 99, 88, 45, 56, 67]
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
1
January: 55
Fabruary: 66
March: 77
April: 44
May: 33
June: 22
July: 11
August: 99
September: 88
October: 45
November: 56
December: 67
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
2
8. The total rainfall is :663
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
3
The average rainfall is :55.25
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
4
The maximum rainfall is :99
The maximum rainfall month is :August
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
5
The minimum rainfall is :11
The minimum rainfall month is :July
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
9. 3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
6
Enter a month (1-12) for rainfall update:
7
Enter rainfall for update:
99
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
4
The maximum rainfall is :99
The maximum rainfall month is :July
Enter your choice:
1.the rainfall for each month
2.the total rainfall for the year
3.find the average monthly rainfall
4.the name of the month with the most rain
.5.the name of the month with the least rain.
6.update the amount of rain in any given month
7.quit
7