Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class rainfallData {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- //inputs
- double calledrainfall[] = {1.0, 1.5, 2.3, 3.1, 1.6, 2.8, 3.0, 1.7, 2.5, 4.0};
- String date[] = {"6th January", "13th January", "20th January", "27th January", "3rd February", "10th February", "17th February", "24th February", "4th March", "11th March"};
- double temp1;
- String temp2;
- for(int i=0; i<calledrainfall.length; i++)
- {
- for(int j=1; j<(calledrainfall.length-i); j++)
- {
- if(calledrainfall[j-1]<calledrainfall[j])
- {
- temp1 = calledrainfall[j-1];
- calledrainfall[j-1] = calledrainfall[j];
- calledrainfall[j] = temp1;
- temp2 = date[j-1];
- date [j-1] = date[j];
- date [j] = temp2;
- }
- }
- }
- for(int i=0; i<date.length; i++)
- System.out.println("The highest rainfall was " + calledrainfall[i] + " cm on " + date[i]);
- }//class ends
- }//program ends
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement