SlideShare a Scribd company logo
//tested on Eclipse
/*************Rainfall.java*************/
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class RainFall {
/*Data member variable*/
private double monthlyRainFall;
private double monthsRainFall[]=new double[12];
private int month=0;
private double maxRain=0.0;
private int maxrainMonth;
private double minRain=0.0;
private int minRainMonth;
/*creating map for storing month*/
Map monthMap=new HashMap();
Scanner input=new Scanner(System.in);
/*Initializing map with value while default constructor*/
public RainFall(){
monthMap.put(0, "January");
monthMap.put(1, "February");
monthMap.put(2, "March");
monthMap.put(3, "April");
monthMap.put(4, "May");
monthMap.put(5, "June");
monthMap.put(6, "July");
monthMap.put(7, "August");
monthMap.put(8, "September");
monthMap.put(9, "October");
monthMap.put(10, "November");
monthMap.put(11, "December");
}
/*Getting monthlyRainFall*/
public double getMonthlyRainFall() {
return monthlyRainFall;
}
/*Setting monthly rainfall If it is negative then it loops until positive */
public void setMonthlyRainFall(double monthlyRainFall) {
while(monthlyRainFall<0){
System.out.println("Please Enter positive value of monthly rainfall");
monthlyRainFall=input.nextDouble();
}
monthsRainFall[month++]=monthlyRainFall;
}
/*Getting average month rain fall*/
public void averageMonthlyRainFall(){
double totalRainFall=0;
/*first calculate totalRain fall after that divide it total month*/
for(int i=0;imonthsRainFall[i]){
minRain=monthsRainFall[i];
minRainMonth=i;
}
}
System.out.println("Min Rain Month Fall: "+monthMap.get(minRainMonth));
}
/*Main method start*/
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
/*Creating instance of rainFall class*/
RainFall rainFall=new RainFall();
/*getting rainfall for each month from user*/
for(int i=0;i<12;i++){
System.out.println("Please Enter rainFall for "+(i+1)+" Month");
rainFall.setMonthlyRainFall(sc.nextDouble());
}
/*Average Monthly rainfall*/
rainFall.averageMonthlyRainFall();
/*Total Rain Fall in a year*/
rainFall.totalRainFall();
/*Max rainFall Month*/
rainFall.maxRainFallMonth();
/*Minimum rainFall Month*/
rainFall.minRainFallMonth();
sc.close();
}
}
/***************output************/
Please Enter rainFall for 1 Month
121
Please Enter rainFall for 2 Month
134
Please Enter rainFall for 3 Month
54
Please Enter rainFall for 4 Month
167
Please Enter rainFall for 5 Month
256
Please Enter rainFall for 6 Month
456
Please Enter rainFall for 7 Month
78
Please Enter rainFall for 8 Month
290
Please Enter rainFall for 9 Month
176
Please Enter rainFall for 10 Month
263
Please Enter rainFall for 11 Month
100
Please Enter rainFall for 12 Month
189
Average Monthly Rain Fall: 190.33
Total Rain Fall for the year: 2284
Max Rain Month Fall: June
Min Rain Month Fall: March
Thanks a lot. If you have any doubt. Please let me know
Solution
//tested on Eclipse
/*************Rainfall.java*************/
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class RainFall {
/*Data member variable*/
private double monthlyRainFall;
private double monthsRainFall[]=new double[12];
private int month=0;
private double maxRain=0.0;
private int maxrainMonth;
private double minRain=0.0;
private int minRainMonth;
/*creating map for storing month*/
Map monthMap=new HashMap();
Scanner input=new Scanner(System.in);
/*Initializing map with value while default constructor*/
public RainFall(){
monthMap.put(0, "January");
monthMap.put(1, "February");
monthMap.put(2, "March");
monthMap.put(3, "April");
monthMap.put(4, "May");
monthMap.put(5, "June");
monthMap.put(6, "July");
monthMap.put(7, "August");
monthMap.put(8, "September");
monthMap.put(9, "October");
monthMap.put(10, "November");
monthMap.put(11, "December");
}
/*Getting monthlyRainFall*/
public double getMonthlyRainFall() {
return monthlyRainFall;
}
/*Setting monthly rainfall If it is negative then it loops until positive */
public void setMonthlyRainFall(double monthlyRainFall) {
while(monthlyRainFall<0){
System.out.println("Please Enter positive value of monthly rainfall");
monthlyRainFall=input.nextDouble();
}
monthsRainFall[month++]=monthlyRainFall;
}
/*Getting average month rain fall*/
public void averageMonthlyRainFall(){
double totalRainFall=0;
/*first calculate totalRain fall after that divide it total month*/
for(int i=0;imonthsRainFall[i]){
minRain=monthsRainFall[i];
minRainMonth=i;
}
}
System.out.println("Min Rain Month Fall: "+monthMap.get(minRainMonth));
}
/*Main method start*/
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
/*Creating instance of rainFall class*/
RainFall rainFall=new RainFall();
/*getting rainfall for each month from user*/
for(int i=0;i<12;i++){
System.out.println("Please Enter rainFall for "+(i+1)+" Month");
rainFall.setMonthlyRainFall(sc.nextDouble());
}
/*Average Monthly rainfall*/
rainFall.averageMonthlyRainFall();
/*Total Rain Fall in a year*/
rainFall.totalRainFall();
/*Max rainFall Month*/
rainFall.maxRainFallMonth();
/*Minimum rainFall Month*/
rainFall.minRainFallMonth();
sc.close();
}
}
/***************output************/
Please Enter rainFall for 1 Month
121
Please Enter rainFall for 2 Month
134
Please Enter rainFall for 3 Month
54
Please Enter rainFall for 4 Month
167
Please Enter rainFall for 5 Month
256
Please Enter rainFall for 6 Month
456
Please Enter rainFall for 7 Month
78
Please Enter rainFall for 8 Month
290
Please Enter rainFall for 9 Month
176
Please Enter rainFall for 10 Month
263
Please Enter rainFall for 11 Month
100
Please Enter rainFall for 12 Month
189
Average Monthly Rain Fall: 190.33
Total Rain Fall for the year: 2284
Max Rain Month Fall: June
Min Rain Month Fall: March
Thanks a lot. If you have any doubt. Please let me know

More Related Content

More from sutharbharat59

1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf
sutharbharat59
 
1A. The acronym DBLC is used to name the Database Life Cycle.The DBL.pdf
1A. The acronym DBLC is used to name the Database Life Cycle.The DBL.pdf1A. The acronym DBLC is used to name the Database Life Cycle.The DBL.pdf
1A. The acronym DBLC is used to name the Database Life Cycle.The DBL.pdf
sutharbharat59
 
In chemistry, hybridisation (or hybridization) is.pdf
                     In chemistry, hybridisation (or hybridization) is.pdf                     In chemistry, hybridisation (or hybridization) is.pdf
In chemistry, hybridisation (or hybridization) is.pdf
sutharbharat59
 
RPS 19 stands for ribosomal protein S19. This proteins is synthesise.pdf
RPS 19 stands for ribosomal protein S19. This proteins is synthesise.pdfRPS 19 stands for ribosomal protein S19. This proteins is synthesise.pdf
RPS 19 stands for ribosomal protein S19. This proteins is synthesise.pdf
sutharbharat59
 
y^(iv)-4y=0taking 4y to RHS we gety^(iv) = 4yy^(iii) = integra.pdf
y^(iv)-4y=0taking 4y to RHS we gety^(iv) = 4yy^(iii) = integra.pdfy^(iv)-4y=0taking 4y to RHS we gety^(iv) = 4yy^(iii) = integra.pdf
y^(iv)-4y=0taking 4y to RHS we gety^(iv) = 4yy^(iii) = integra.pdf
sutharbharat59
 
 Fe(s) + Mn2+(aq) Fe2+(aq) + Mn(s)Yes this reaction is spon.pdf
 Fe(s) + Mn2+(aq)  Fe2+(aq) + Mn(s)Yes this reaction is spon.pdf Fe(s) + Mn2+(aq)  Fe2+(aq) + Mn(s)Yes this reaction is spon.pdf
 Fe(s) + Mn2+(aq) Fe2+(aq) + Mn(s)Yes this reaction is spon.pdf
sutharbharat59
 
When Na2SO3 is dissolved in water, Na+ and SO32- ions are formedN.pdf
When Na2SO3 is dissolved in water, Na+ and SO32- ions are formedN.pdfWhen Na2SO3 is dissolved in water, Na+ and SO32- ions are formedN.pdf
When Na2SO3 is dissolved in water, Na+ and SO32- ions are formedN.pdf
sutharbharat59
 
To convert html code into Java servlet you have to write all html ta.pdf
To convert html code into Java servlet you have to write all html ta.pdfTo convert html code into Java servlet you have to write all html ta.pdf
To convert html code into Java servlet you have to write all html ta.pdf
sutharbharat59
 
Therapsids is a group of synapsidsAdaptation1.Four limbs extent.pdf
Therapsids is a group of synapsidsAdaptation1.Four limbs extent.pdfTherapsids is a group of synapsidsAdaptation1.Four limbs extent.pdf
Therapsids is a group of synapsidsAdaptation1.Four limbs extent.pdf
sutharbharat59
 
They trade away higher fecundity for future reproduction.Being ite.pdf
They trade away higher fecundity for future reproduction.Being ite.pdfThey trade away higher fecundity for future reproduction.Being ite.pdf
They trade away higher fecundity for future reproduction.Being ite.pdf
sutharbharat59
 
The statements that are consistent with facts known about membrane a.pdf
The statements that are consistent with facts known about membrane a.pdfThe statements that are consistent with facts known about membrane a.pdf
The statements that are consistent with facts known about membrane a.pdf
sutharbharat59
 
The implementation algorithm whose amortized complexity is O (1) to .pdf
The implementation algorithm whose amortized complexity is O (1) to .pdfThe implementation algorithm whose amortized complexity is O (1) to .pdf
The implementation algorithm whose amortized complexity is O (1) to .pdf
sutharbharat59
 
The correct matches are as discussed below(a) A (Glycoprotiens ar.pdf
The correct matches are as discussed below(a) A (Glycoprotiens ar.pdfThe correct matches are as discussed below(a) A (Glycoprotiens ar.pdf
The correct matches are as discussed below(a) A (Glycoprotiens ar.pdf
sutharbharat59
 
Step1 Moles of He = 504.0026Step2 Moles of Xe = 50131.29Step3 .pdf
Step1 Moles of He = 504.0026Step2 Moles of Xe = 50131.29Step3 .pdfStep1 Moles of He = 504.0026Step2 Moles of Xe = 50131.29Step3 .pdf
Step1 Moles of He = 504.0026Step2 Moles of Xe = 50131.29Step3 .pdf
sutharbharat59
 
SKIN SENSORY ORGANThe human skin is the external covering of the .pdf
SKIN SENSORY ORGANThe human skin is the external covering of the .pdfSKIN SENSORY ORGANThe human skin is the external covering of the .pdf
SKIN SENSORY ORGANThe human skin is the external covering of the .pdf
sutharbharat59
 
a) FlaseIn terms of trasing volume it is by far the largest market.pdf
a) FlaseIn terms of trasing volume it is by far the largest market.pdfa) FlaseIn terms of trasing volume it is by far the largest market.pdf
a) FlaseIn terms of trasing volume it is by far the largest market.pdf
sutharbharat59
 
Ques-1Part-a Mitosis it is a somatic cell division in an organi.pdf
Ques-1Part-a Mitosis it is a somatic cell division in an organi.pdfQues-1Part-a Mitosis it is a somatic cell division in an organi.pdf
Ques-1Part-a Mitosis it is a somatic cell division in an organi.pdf
sutharbharat59
 
Proportional tax is a tax where the rate of tax is fixed. It is a pr.pdf
Proportional tax is a tax where the rate of tax is fixed. It is a pr.pdfProportional tax is a tax where the rate of tax is fixed. It is a pr.pdf
Proportional tax is a tax where the rate of tax is fixed. It is a pr.pdf
sutharbharat59
 
POS system is a networked invironment where a main computer linked t.pdf
POS system is a networked invironment where a main computer linked t.pdfPOS system is a networked invironment where a main computer linked t.pdf
POS system is a networked invironment where a main computer linked t.pdf
sutharbharat59
 
Q) The passage of traits from parents of offspring is called A H.pdf
Q) The passage of traits from parents of offspring is called A H.pdfQ) The passage of traits from parents of offspring is called A H.pdf
Q) The passage of traits from parents of offspring is called A H.pdf
sutharbharat59
 

More from sutharbharat59 (20)

1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf
 
1A. The acronym DBLC is used to name the Database Life Cycle.The DBL.pdf
1A. The acronym DBLC is used to name the Database Life Cycle.The DBL.pdf1A. The acronym DBLC is used to name the Database Life Cycle.The DBL.pdf
1A. The acronym DBLC is used to name the Database Life Cycle.The DBL.pdf
 
In chemistry, hybridisation (or hybridization) is.pdf
                     In chemistry, hybridisation (or hybridization) is.pdf                     In chemistry, hybridisation (or hybridization) is.pdf
In chemistry, hybridisation (or hybridization) is.pdf
 
RPS 19 stands for ribosomal protein S19. This proteins is synthesise.pdf
RPS 19 stands for ribosomal protein S19. This proteins is synthesise.pdfRPS 19 stands for ribosomal protein S19. This proteins is synthesise.pdf
RPS 19 stands for ribosomal protein S19. This proteins is synthesise.pdf
 
y^(iv)-4y=0taking 4y to RHS we gety^(iv) = 4yy^(iii) = integra.pdf
y^(iv)-4y=0taking 4y to RHS we gety^(iv) = 4yy^(iii) = integra.pdfy^(iv)-4y=0taking 4y to RHS we gety^(iv) = 4yy^(iii) = integra.pdf
y^(iv)-4y=0taking 4y to RHS we gety^(iv) = 4yy^(iii) = integra.pdf
 
 Fe(s) + Mn2+(aq) Fe2+(aq) + Mn(s)Yes this reaction is spon.pdf
 Fe(s) + Mn2+(aq)  Fe2+(aq) + Mn(s)Yes this reaction is spon.pdf Fe(s) + Mn2+(aq)  Fe2+(aq) + Mn(s)Yes this reaction is spon.pdf
 Fe(s) + Mn2+(aq) Fe2+(aq) + Mn(s)Yes this reaction is spon.pdf
 
When Na2SO3 is dissolved in water, Na+ and SO32- ions are formedN.pdf
When Na2SO3 is dissolved in water, Na+ and SO32- ions are formedN.pdfWhen Na2SO3 is dissolved in water, Na+ and SO32- ions are formedN.pdf
When Na2SO3 is dissolved in water, Na+ and SO32- ions are formedN.pdf
 
To convert html code into Java servlet you have to write all html ta.pdf
To convert html code into Java servlet you have to write all html ta.pdfTo convert html code into Java servlet you have to write all html ta.pdf
To convert html code into Java servlet you have to write all html ta.pdf
 
Therapsids is a group of synapsidsAdaptation1.Four limbs extent.pdf
Therapsids is a group of synapsidsAdaptation1.Four limbs extent.pdfTherapsids is a group of synapsidsAdaptation1.Four limbs extent.pdf
Therapsids is a group of synapsidsAdaptation1.Four limbs extent.pdf
 
They trade away higher fecundity for future reproduction.Being ite.pdf
They trade away higher fecundity for future reproduction.Being ite.pdfThey trade away higher fecundity for future reproduction.Being ite.pdf
They trade away higher fecundity for future reproduction.Being ite.pdf
 
The statements that are consistent with facts known about membrane a.pdf
The statements that are consistent with facts known about membrane a.pdfThe statements that are consistent with facts known about membrane a.pdf
The statements that are consistent with facts known about membrane a.pdf
 
The implementation algorithm whose amortized complexity is O (1) to .pdf
The implementation algorithm whose amortized complexity is O (1) to .pdfThe implementation algorithm whose amortized complexity is O (1) to .pdf
The implementation algorithm whose amortized complexity is O (1) to .pdf
 
The correct matches are as discussed below(a) A (Glycoprotiens ar.pdf
The correct matches are as discussed below(a) A (Glycoprotiens ar.pdfThe correct matches are as discussed below(a) A (Glycoprotiens ar.pdf
The correct matches are as discussed below(a) A (Glycoprotiens ar.pdf
 
Step1 Moles of He = 504.0026Step2 Moles of Xe = 50131.29Step3 .pdf
Step1 Moles of He = 504.0026Step2 Moles of Xe = 50131.29Step3 .pdfStep1 Moles of He = 504.0026Step2 Moles of Xe = 50131.29Step3 .pdf
Step1 Moles of He = 504.0026Step2 Moles of Xe = 50131.29Step3 .pdf
 
SKIN SENSORY ORGANThe human skin is the external covering of the .pdf
SKIN SENSORY ORGANThe human skin is the external covering of the .pdfSKIN SENSORY ORGANThe human skin is the external covering of the .pdf
SKIN SENSORY ORGANThe human skin is the external covering of the .pdf
 
a) FlaseIn terms of trasing volume it is by far the largest market.pdf
a) FlaseIn terms of trasing volume it is by far the largest market.pdfa) FlaseIn terms of trasing volume it is by far the largest market.pdf
a) FlaseIn terms of trasing volume it is by far the largest market.pdf
 
Ques-1Part-a Mitosis it is a somatic cell division in an organi.pdf
Ques-1Part-a Mitosis it is a somatic cell division in an organi.pdfQues-1Part-a Mitosis it is a somatic cell division in an organi.pdf
Ques-1Part-a Mitosis it is a somatic cell division in an organi.pdf
 
Proportional tax is a tax where the rate of tax is fixed. It is a pr.pdf
Proportional tax is a tax where the rate of tax is fixed. It is a pr.pdfProportional tax is a tax where the rate of tax is fixed. It is a pr.pdf
Proportional tax is a tax where the rate of tax is fixed. It is a pr.pdf
 
POS system is a networked invironment where a main computer linked t.pdf
POS system is a networked invironment where a main computer linked t.pdfPOS system is a networked invironment where a main computer linked t.pdf
POS system is a networked invironment where a main computer linked t.pdf
 
Q) The passage of traits from parents of offspring is called A H.pdf
Q) The passage of traits from parents of offspring is called A H.pdfQ) The passage of traits from parents of offspring is called A H.pdf
Q) The passage of traits from parents of offspring is called A H.pdf
 

Recently uploaded

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 

Recently uploaded (20)

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 

tested on EclipseRainfall.javaimpo.pdf

  • 1. //tested on Eclipse /*************Rainfall.java*************/ import java.text.DecimalFormat; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class RainFall { /*Data member variable*/ private double monthlyRainFall; private double monthsRainFall[]=new double[12]; private int month=0; private double maxRain=0.0; private int maxrainMonth; private double minRain=0.0; private int minRainMonth; /*creating map for storing month*/ Map monthMap=new HashMap(); Scanner input=new Scanner(System.in); /*Initializing map with value while default constructor*/ public RainFall(){ monthMap.put(0, "January"); monthMap.put(1, "February"); monthMap.put(2, "March"); monthMap.put(3, "April"); monthMap.put(4, "May"); monthMap.put(5, "June"); monthMap.put(6, "July"); monthMap.put(7, "August"); monthMap.put(8, "September"); monthMap.put(9, "October"); monthMap.put(10, "November"); monthMap.put(11, "December"); } /*Getting monthlyRainFall*/ public double getMonthlyRainFall() {
  • 2. return monthlyRainFall; } /*Setting monthly rainfall If it is negative then it loops until positive */ public void setMonthlyRainFall(double monthlyRainFall) { while(monthlyRainFall<0){ System.out.println("Please Enter positive value of monthly rainfall"); monthlyRainFall=input.nextDouble(); } monthsRainFall[month++]=monthlyRainFall; } /*Getting average month rain fall*/ public void averageMonthlyRainFall(){ double totalRainFall=0; /*first calculate totalRain fall after that divide it total month*/ for(int i=0;imonthsRainFall[i]){ minRain=monthsRainFall[i]; minRainMonth=i; } } System.out.println("Min Rain Month Fall: "+monthMap.get(minRainMonth)); } /*Main method start*/ public static void main(String[] args) { Scanner sc=new Scanner(System.in); /*Creating instance of rainFall class*/ RainFall rainFall=new RainFall(); /*getting rainfall for each month from user*/ for(int i=0;i<12;i++){ System.out.println("Please Enter rainFall for "+(i+1)+" Month"); rainFall.setMonthlyRainFall(sc.nextDouble()); } /*Average Monthly rainfall*/ rainFall.averageMonthlyRainFall(); /*Total Rain Fall in a year*/ rainFall.totalRainFall();
  • 3. /*Max rainFall Month*/ rainFall.maxRainFallMonth(); /*Minimum rainFall Month*/ rainFall.minRainFallMonth(); sc.close(); } } /***************output************/ Please Enter rainFall for 1 Month 121 Please Enter rainFall for 2 Month 134 Please Enter rainFall for 3 Month 54 Please Enter rainFall for 4 Month 167 Please Enter rainFall for 5 Month 256 Please Enter rainFall for 6 Month 456 Please Enter rainFall for 7 Month 78 Please Enter rainFall for 8 Month 290 Please Enter rainFall for 9 Month 176 Please Enter rainFall for 10 Month 263 Please Enter rainFall for 11 Month 100 Please Enter rainFall for 12 Month 189 Average Monthly Rain Fall: 190.33 Total Rain Fall for the year: 2284 Max Rain Month Fall: June Min Rain Month Fall: March
  • 4. Thanks a lot. If you have any doubt. Please let me know Solution //tested on Eclipse /*************Rainfall.java*************/ import java.text.DecimalFormat; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class RainFall { /*Data member variable*/ private double monthlyRainFall; private double monthsRainFall[]=new double[12]; private int month=0; private double maxRain=0.0; private int maxrainMonth; private double minRain=0.0; private int minRainMonth; /*creating map for storing month*/ Map monthMap=new HashMap(); Scanner input=new Scanner(System.in); /*Initializing map with value while default constructor*/ public RainFall(){ monthMap.put(0, "January"); monthMap.put(1, "February"); monthMap.put(2, "March"); monthMap.put(3, "April"); monthMap.put(4, "May"); monthMap.put(5, "June"); monthMap.put(6, "July"); monthMap.put(7, "August"); monthMap.put(8, "September"); monthMap.put(9, "October"); monthMap.put(10, "November");
  • 5. monthMap.put(11, "December"); } /*Getting monthlyRainFall*/ public double getMonthlyRainFall() { return monthlyRainFall; } /*Setting monthly rainfall If it is negative then it loops until positive */ public void setMonthlyRainFall(double monthlyRainFall) { while(monthlyRainFall<0){ System.out.println("Please Enter positive value of monthly rainfall"); monthlyRainFall=input.nextDouble(); } monthsRainFall[month++]=monthlyRainFall; } /*Getting average month rain fall*/ public void averageMonthlyRainFall(){ double totalRainFall=0; /*first calculate totalRain fall after that divide it total month*/ for(int i=0;imonthsRainFall[i]){ minRain=monthsRainFall[i]; minRainMonth=i; } } System.out.println("Min Rain Month Fall: "+monthMap.get(minRainMonth)); } /*Main method start*/ public static void main(String[] args) { Scanner sc=new Scanner(System.in); /*Creating instance of rainFall class*/ RainFall rainFall=new RainFall(); /*getting rainfall for each month from user*/ for(int i=0;i<12;i++){ System.out.println("Please Enter rainFall for "+(i+1)+" Month"); rainFall.setMonthlyRainFall(sc.nextDouble()); }
  • 6. /*Average Monthly rainfall*/ rainFall.averageMonthlyRainFall(); /*Total Rain Fall in a year*/ rainFall.totalRainFall(); /*Max rainFall Month*/ rainFall.maxRainFallMonth(); /*Minimum rainFall Month*/ rainFall.minRainFallMonth(); sc.close(); } } /***************output************/ Please Enter rainFall for 1 Month 121 Please Enter rainFall for 2 Month 134 Please Enter rainFall for 3 Month 54 Please Enter rainFall for 4 Month 167 Please Enter rainFall for 5 Month 256 Please Enter rainFall for 6 Month 456 Please Enter rainFall for 7 Month 78 Please Enter rainFall for 8 Month 290 Please Enter rainFall for 9 Month 176 Please Enter rainFall for 10 Month 263 Please Enter rainFall for 11 Month 100 Please Enter rainFall for 12 Month 189
  • 7. Average Monthly Rain Fall: 190.33 Total Rain Fall for the year: 2284 Max Rain Month Fall: June Min Rain Month Fall: March Thanks a lot. If you have any doubt. Please let me know