SlideShare a Scribd company logo
1 of 4
Download to read offline
In JAVA
Write a program that uses a two-dimensional array to store the highest and lowest temperatures
for each month of the year. The program should output the average high, average low, and
highest and lowest temperatures of the year. Your program must consist of the following
methods:
a. Method getData: This method reads and stores the data in the two-dimensional array.
b. Method averageHigh: This method calculates and returns the average high temperature of the
year.
c. Method averageLow: This method calculates and returns the average low temperature of the
year.
d. Method indexHighTemp: This method returns the index of the highest temperature in the
array.
e. Method indexLowTemp: This method returns the index of the lowest temperature in the array.
(These methods must all have the appropriate parameters.)
Solution
CODE
package test;
import java.util.Scanner;
public class Temperatures {
//declaring temperatures as a static array
public static double[][] temperatures = new double[12][2];
public static void main(String[] args) {
getData();
System.out.println("Average high is : "+averageHigh());
System.out.println("Average low is : "+averageLow());
System.out.println("Month of highest temperature is : "+indexHighTemp());
System.out.println("Month of lowest temperature is : "+indexLowTemp());
}
//to get data of temperatures for all months from user
public static void getData() {
System.out.println("Enter details");
Scanner in = new Scanner(System.in);
for (int i = 0; i < 12; i++) {
System.out.println("Enter highest temperature for month " + (i + 1));
temperatures[i][0] = in.nextDouble();
System.out.println("Enter lowest temperature for month " + (i + 1));
temperatures[i][1] = in.nextDouble();
}
}
//to get avegare of highest temperatures of all months
public static double averageHigh() {
double avg = 0;
for (int i = 0; i < 12; i++) {
avg += temperatures[i][0];
}
return avg / 12;
}
//to get sverage of lowest temperatures of all months
public static double averageLow() {
double avg = 0;
for (int i = 0; i < 12; i++) {
avg += temperatures[i][1];
}
return avg / 12;
}
//to get index of highest tempeartures of all months
public static int indexHighTemp() {
int index = 0;
double max = Double.MIN_VALUE;
for (int i = 0; i < 12; i++)
if (temperatures[i][0] > max)
{
index = i;
max =temperatures[i][0];
}
return index+1;
}
//to get index of lowest tempeartures of all months
public static int indexLowTemp() {
int index = 0;
double min = Double.MAX_VALUE;
for (int i = 0; i < 12; i++)
if (temperatures[i][1] < min)
{
index = i;
min = temperatures[i][1];
}
return index+1;
}
}
SAMPLE OUTPUT
Enter details
Enter highest temperature for month 1
60
Enter lowest temperature for month 1
50
Enter highest temperature for month 2
50
Enter lowest temperature for month 2
40
Enter highest temperature for month 3
40
Enter lowest temperature for month 3
30
Enter highest temperature for month 4
30
Enter lowest temperature for month 4
20
Enter highest temperature for month 5
20
Enter lowest temperature for month 5
10
Enter highest temperature for month 6
20
Enter lowest temperature for month 6
10
Enter highest temperature for month 7
30
Enter lowest temperature for month 7
20
Enter highest temperature for month 8
40
Enter lowest temperature for month 8
30
Enter highest temperature for month 9
50
Enter lowest temperature for month 9
40
Enter highest temperature for month 10
60
Enter lowest temperature for month 10
50
Enter highest temperature for month 11
70
Enter lowest temperature for month 11
60
Enter highest temperature for month 12
80
Enter lowest temperature for month 12
70
Average high is : 45.833333333333336
Average low is : 35.833333333333336
Index of highest temperature is : 11
Index of lowest temperature is : 4

More Related Content

Similar to In JAVA Write a program that uses a two-dimensional array to sto.pdf

Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdfStep 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf
aloeplusint
 
Program 1 (Practicing an example of function using call by referenc.pdf
Program 1 (Practicing an example of function using call by referenc.pdfProgram 1 (Practicing an example of function using call by referenc.pdf
Program 1 (Practicing an example of function using call by referenc.pdf
ezhilvizhiyan
 
Write a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdfWrite a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdf
fashioncollection2
 
An object of class StatCalc can be used to compute several simp.pdf
 An object of class StatCalc can be used to compute several simp.pdf An object of class StatCalc can be used to compute several simp.pdf
An object of class StatCalc can be used to compute several simp.pdf
aravlitraders2012
 

Similar to In JAVA Write a program that uses a two-dimensional array to sto.pdf (17)

Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdfStep 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdf
 
Program Design
Program DesignProgram Design
Program Design
 
PART 6: FROM GEO INTO YOUR REPORT
PART 6: FROM GEO INTO YOUR REPORTPART 6: FROM GEO INTO YOUR REPORT
PART 6: FROM GEO INTO YOUR REPORT
 
Program 1 (Practicing an example of function using call by referenc.pdf
Program 1 (Practicing an example of function using call by referenc.pdfProgram 1 (Practicing an example of function using call by referenc.pdf
Program 1 (Practicing an example of function using call by referenc.pdf
 
Java conceptual learning material
Java conceptual learning materialJava conceptual learning material
Java conceptual learning material
 
C programming Lab 2
C programming Lab 2C programming Lab 2
C programming Lab 2
 
C important questions
C important questionsC important questions
C important questions
 
Write a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdfWrite a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdf
 
public class Interest{double interest(double rate, double amount){.pdf
public class Interest{double interest(double rate, double amount){.pdfpublic class Interest{double interest(double rate, double amount){.pdf
public class Interest{double interest(double rate, double amount){.pdf
 
Lab 1
Lab 1Lab 1
Lab 1
 
TIME SERIES ANALYSIS USING ARIMA MODEL FOR FORECASTING IN R (PRACTICAL)
TIME SERIES ANALYSIS USING ARIMA MODEL FOR FORECASTING IN R (PRACTICAL)TIME SERIES ANALYSIS USING ARIMA MODEL FOR FORECASTING IN R (PRACTICAL)
TIME SERIES ANALYSIS USING ARIMA MODEL FOR FORECASTING IN R (PRACTICAL)
 
An object of class StatCalc can be used to compute several simp.pdf
 An object of class StatCalc can be used to compute several simp.pdf An object of class StatCalc can be used to compute several simp.pdf
An object of class StatCalc can be used to compute several simp.pdf
 
Using the code below Part 1 Write a static method called L.pdf
Using the code below Part 1 Write a static method called L.pdfUsing the code below Part 1 Write a static method called L.pdf
Using the code below Part 1 Write a static method called L.pdf
 
Dynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using TimeDynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using Time
 
Assignment Java Programming 2
Assignment Java Programming 2Assignment Java Programming 2
Assignment Java Programming 2
 
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
 
functions
functionsfunctions
functions
 

More from info309708

Loops and ArraysObjectivesArrays are a series of elements consi.pdf
Loops and ArraysObjectivesArrays are a series of elements consi.pdfLoops and ArraysObjectivesArrays are a series of elements consi.pdf
Loops and ArraysObjectivesArrays are a series of elements consi.pdf
info309708
 
Its your third week on the job at Panache Inc. Last week, you made.pdf
Its your third week on the job at Panache Inc. Last week, you made.pdfIts your third week on the job at Panache Inc. Last week, you made.pdf
Its your third week on the job at Panache Inc. Last week, you made.pdf
info309708
 
How would you implement a node classs and an edge class to create .pdf
How would you implement a node classs and an edge class to create .pdfHow would you implement a node classs and an edge class to create .pdf
How would you implement a node classs and an edge class to create .pdf
info309708
 
How do you evaluate your own global mind set levelsSolutionAN.pdf
How do you evaluate your own global mind set levelsSolutionAN.pdfHow do you evaluate your own global mind set levelsSolutionAN.pdf
How do you evaluate your own global mind set levelsSolutionAN.pdf
info309708
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
info309708
 
For this homework, you will develop a class called VendingMachine th.pdf
For this homework, you will develop a class called VendingMachine th.pdfFor this homework, you will develop a class called VendingMachine th.pdf
For this homework, you will develop a class called VendingMachine th.pdf
info309708
 
Describe the differences between the three major physical connection .pdf
Describe the differences between the three major physical connection .pdfDescribe the differences between the three major physical connection .pdf
Describe the differences between the three major physical connection .pdf
info309708
 
Create a student record management system using linked list and queu.pdf
Create a student record management system using linked list and queu.pdfCreate a student record management system using linked list and queu.pdf
Create a student record management system using linked list and queu.pdf
info309708
 
C programming. Answer question only in C code Ninth Deletion with B.pdf
C programming. Answer question only in C code Ninth Deletion with B.pdfC programming. Answer question only in C code Ninth Deletion with B.pdf
C programming. Answer question only in C code Ninth Deletion with B.pdf
info309708
 
Aside from the expansion of industrial capitalism, what factors affe.pdf
Aside from the expansion of industrial capitalism, what factors affe.pdfAside from the expansion of industrial capitalism, what factors affe.pdf
Aside from the expansion of industrial capitalism, what factors affe.pdf
info309708
 

More from info309708 (20)

Pluto has been hard to measure from Earth because of its atmosphere. .pdf
Pluto has been hard to measure from Earth because of its atmosphere. .pdfPluto has been hard to measure from Earth because of its atmosphere. .pdf
Pluto has been hard to measure from Earth because of its atmosphere. .pdf
 
Loops and ArraysObjectivesArrays are a series of elements consi.pdf
Loops and ArraysObjectivesArrays are a series of elements consi.pdfLoops and ArraysObjectivesArrays are a series of elements consi.pdf
Loops and ArraysObjectivesArrays are a series of elements consi.pdf
 
Modern Database Management 11th Edition by Jeffrey A. HofferUse th.pdf
Modern Database Management 11th Edition by Jeffrey A. HofferUse th.pdfModern Database Management 11th Edition by Jeffrey A. HofferUse th.pdf
Modern Database Management 11th Edition by Jeffrey A. HofferUse th.pdf
 
Let f X Y be a function.True or FalseA sufficient condition for f .pdf
Let f X Y be a function.True or FalseA sufficient condition for f .pdfLet f X Y be a function.True or FalseA sufficient condition for f .pdf
Let f X Y be a function.True or FalseA sufficient condition for f .pdf
 
Its your third week on the job at Panache Inc. Last week, you made.pdf
Its your third week on the job at Panache Inc. Last week, you made.pdfIts your third week on the job at Panache Inc. Last week, you made.pdf
Its your third week on the job at Panache Inc. Last week, you made.pdf
 
How do CCMI model help with the improvements and comparison of the p.pdf
How do CCMI model help with the improvements and comparison of the p.pdfHow do CCMI model help with the improvements and comparison of the p.pdf
How do CCMI model help with the improvements and comparison of the p.pdf
 
How would you implement a node classs and an edge class to create .pdf
How would you implement a node classs and an edge class to create .pdfHow would you implement a node classs and an edge class to create .pdf
How would you implement a node classs and an edge class to create .pdf
 
How do you evaluate your own global mind set levelsSolutionAN.pdf
How do you evaluate your own global mind set levelsSolutionAN.pdfHow do you evaluate your own global mind set levelsSolutionAN.pdf
How do you evaluate your own global mind set levelsSolutionAN.pdf
 
Here are two datasetsDataset A 64 65 66 68 70 71 72Dataset B .pdf
Here are two datasetsDataset A 64 65 66 68 70 71 72Dataset B .pdfHere are two datasetsDataset A 64 65 66 68 70 71 72Dataset B .pdf
Here are two datasetsDataset A 64 65 66 68 70 71 72Dataset B .pdf
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
 
For this homework, you will develop a class called VendingMachine th.pdf
For this homework, you will develop a class called VendingMachine th.pdfFor this homework, you will develop a class called VendingMachine th.pdf
For this homework, you will develop a class called VendingMachine th.pdf
 
Discuss what is SSH and the advantages and disadvantages of using it.pdf
Discuss what is SSH and the advantages and disadvantages of using it.pdfDiscuss what is SSH and the advantages and disadvantages of using it.pdf
Discuss what is SSH and the advantages and disadvantages of using it.pdf
 
Describe the differences between the three major physical connection .pdf
Describe the differences between the three major physical connection .pdfDescribe the differences between the three major physical connection .pdf
Describe the differences between the three major physical connection .pdf
 
Create a student record management system using linked list and queu.pdf
Create a student record management system using linked list and queu.pdfCreate a student record management system using linked list and queu.pdf
Create a student record management system using linked list and queu.pdf
 
Coca-Cola companyStrategic Goals and Objectivesi. Objectives are.pdf
Coca-Cola companyStrategic Goals and Objectivesi. Objectives are.pdfCoca-Cola companyStrategic Goals and Objectivesi. Objectives are.pdf
Coca-Cola companyStrategic Goals and Objectivesi. Objectives are.pdf
 
C programming. Answer question only in C code Ninth Deletion with B.pdf
C programming. Answer question only in C code Ninth Deletion with B.pdfC programming. Answer question only in C code Ninth Deletion with B.pdf
C programming. Answer question only in C code Ninth Deletion with B.pdf
 
Biology LabThe poisonous wastes of diptheria germs are called (A).pdf
Biology LabThe poisonous wastes of diptheria germs are called (A).pdfBiology LabThe poisonous wastes of diptheria germs are called (A).pdf
Biology LabThe poisonous wastes of diptheria germs are called (A).pdf
 
Aside from the expansion of industrial capitalism, what factors affe.pdf
Aside from the expansion of industrial capitalism, what factors affe.pdfAside from the expansion of industrial capitalism, what factors affe.pdf
Aside from the expansion of industrial capitalism, what factors affe.pdf
 
Yates (2009) notes that unions have a purpose broader than serving t.pdf
Yates (2009) notes that unions have a purpose broader than serving t.pdfYates (2009) notes that unions have a purpose broader than serving t.pdf
Yates (2009) notes that unions have a purpose broader than serving t.pdf
 
write a C program for blinking light using function make sure it.pdf
write a C program for blinking light using function make sure it.pdfwrite a C program for blinking light using function make sure it.pdf
write a C program for blinking light using function make sure it.pdf
 

Recently uploaded

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 

Recently uploaded (20)

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 

In JAVA Write a program that uses a two-dimensional array to sto.pdf

  • 1. In JAVA Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. The program should output the average high, average low, and highest and lowest temperatures of the year. Your program must consist of the following methods: a. Method getData: This method reads and stores the data in the two-dimensional array. b. Method averageHigh: This method calculates and returns the average high temperature of the year. c. Method averageLow: This method calculates and returns the average low temperature of the year. d. Method indexHighTemp: This method returns the index of the highest temperature in the array. e. Method indexLowTemp: This method returns the index of the lowest temperature in the array. (These methods must all have the appropriate parameters.) Solution CODE package test; import java.util.Scanner; public class Temperatures { //declaring temperatures as a static array public static double[][] temperatures = new double[12][2]; public static void main(String[] args) { getData(); System.out.println("Average high is : "+averageHigh()); System.out.println("Average low is : "+averageLow()); System.out.println("Month of highest temperature is : "+indexHighTemp()); System.out.println("Month of lowest temperature is : "+indexLowTemp()); } //to get data of temperatures for all months from user public static void getData() { System.out.println("Enter details");
  • 2. Scanner in = new Scanner(System.in); for (int i = 0; i < 12; i++) { System.out.println("Enter highest temperature for month " + (i + 1)); temperatures[i][0] = in.nextDouble(); System.out.println("Enter lowest temperature for month " + (i + 1)); temperatures[i][1] = in.nextDouble(); } } //to get avegare of highest temperatures of all months public static double averageHigh() { double avg = 0; for (int i = 0; i < 12; i++) { avg += temperatures[i][0]; } return avg / 12; } //to get sverage of lowest temperatures of all months public static double averageLow() { double avg = 0; for (int i = 0; i < 12; i++) { avg += temperatures[i][1]; } return avg / 12; } //to get index of highest tempeartures of all months public static int indexHighTemp() { int index = 0; double max = Double.MIN_VALUE; for (int i = 0; i < 12; i++) if (temperatures[i][0] > max) { index = i; max =temperatures[i][0]; } return index+1; }
  • 3. //to get index of lowest tempeartures of all months public static int indexLowTemp() { int index = 0; double min = Double.MAX_VALUE; for (int i = 0; i < 12; i++) if (temperatures[i][1] < min) { index = i; min = temperatures[i][1]; } return index+1; } } SAMPLE OUTPUT Enter details Enter highest temperature for month 1 60 Enter lowest temperature for month 1 50 Enter highest temperature for month 2 50 Enter lowest temperature for month 2 40 Enter highest temperature for month 3 40 Enter lowest temperature for month 3 30 Enter highest temperature for month 4 30 Enter lowest temperature for month 4 20 Enter highest temperature for month 5 20 Enter lowest temperature for month 5 10
  • 4. Enter highest temperature for month 6 20 Enter lowest temperature for month 6 10 Enter highest temperature for month 7 30 Enter lowest temperature for month 7 20 Enter highest temperature for month 8 40 Enter lowest temperature for month 8 30 Enter highest temperature for month 9 50 Enter lowest temperature for month 9 40 Enter highest temperature for month 10 60 Enter lowest temperature for month 10 50 Enter highest temperature for month 11 70 Enter lowest temperature for month 11 60 Enter highest temperature for month 12 80 Enter lowest temperature for month 12 70 Average high is : 45.833333333333336 Average low is : 35.833333333333336 Index of highest temperature is : 11 Index of lowest temperature is : 4