java - Need quick help on rainfall statistics program -


Basically I'm having a hard time keeping this program together, which is designed to ask users They want to see how many years of data they use, and depending on that input, this is how many set random double rain values ​​of 12 months are displayed.

This is the product that should appear if the user enters in 3 years:

Enter the year number: 3

1 Rain volume < / P>

Month 1 Rainfall was 4.16 Month 2 Rainfall 6.85 Month 3 Rainfall 1.28 Months 4 Rainfall Amount 1.66 Month 5 Rainfall Amount 3.06 Months 6 Rainfall 4.62 Month 7 Rainfall 5.6 9 Month 8 Rainfall Amount 1.84 months 9 rain was 9.63, 9 months amount 10 rain was 8.60 month 11 amount was 3.34 months 12 rain Amount was 1.27

Year 2 Rainfall Amount

Month 1 Rainfall 4.38 Months 2 Rainfall Was 4.64 Months 3 Rainfall 8.27 Months 4 Rainfall 3.19 Month 5 Rainfall 6.6 9 Months 6 Rainfall was 4.13 months 7 Rainfall 8.52 months 8 Rainfall was 5.71 months 9 Rainfall 3. 9 1 month 10 Rainfall amount 9.16 months 11 Rainfall amount 3.47 months 12 Rainfall amount 7.90

Year 3 years was the volume

Month 1 rain amount 2.73 months 2 rainfall amount 2.92 months 3 rainfall amount 7.98 months 4 rain zodiac 2.82 months 5 rain zodiac 3.73 was the month 6 rain was the amount 3.00 months 7 rainfall 0.14 months 8 rain 9.98 months 9 rainfall amount 5.34 month 10 rain 8.12 months 11 rainfall amount 8.66 months 12 rainfall amount was 4.21

Number in months: 36 total rain: 181.62 inches average monthly rainfall: 5.04 inch

What I'm doing thus far:

  import java .util. *; / ** This class creates a program that receives the amount of rain for each year * / Public Class RainfallStats {/ ** The starting point of the main method program is * / public static zero main (string [] args) {int Years = 0; Double months = 0; Final integer numbers = 12; Scanner Keyboard = New Scanner (System.in); Random Generator = New Random (); System.out.println ("Enter the number of years:"); Year = keyboard.nextInt (); While (year & lt; 1) {System.out.println ("invalid. Enter at least one year"); Year = keyboard.nextInt (); } For (int y = 1; y and lt; = year; y ++) {System.out.println ("year" + y + "volume of rainfall"); Println (); } (Int m = 1; m & lt; = numberMonths; m ++) {System.out.println ("month" + m + "volume of rainfall");  

I just need help in the loop and find out how to put a different random double value after every statement of the month. I know that I have some things in order and I am missing a lot, but I appreciate any signs or suggestions. Thanks!

maxRainfall , which is the final By using variable, you can get a random decimal using nextDouble function java.util.Random , and multiply it by your maxRainfall :

  Dual month range = generator.nx double () * maxRainfall  

then you can do that new random double Also, which can 0 and max-rayflele

During the months of the appropriate year, for all months instead of all years, for months within the loop for the nest years of your loop:

  (int y = 1 ; Y & lt; = years; y ++) {System.out.println ("year" + y + "rainfall was quantity"); Println (); (Int m = 1; m & lt; = numberMonths; m ++) {System.out.println ("month" + m + "volume of rainfall"); // to generate random random code}}  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -