Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: Help writing this code

1. ## Help writing this code

New York City temperature ranges for 12 months are given below:
Jan Feb Mar Apr May JunJul Aug Sep Oct Nov Dec
25–38 26-40 34-4843-58 52-68 62-7768-83 60-75 49-65 41-54 31-43 47-61

1. Create an int array of size 366 to save the daily temperatures for a leap year.
2. Fill the array with randomly generated numbers between the ranges for that month. For example, for the first 31 days of the year (that is the month of January) randomly generate numbers between 25 and 38. For the next 29 days (the Month of February) randomly generate numbers between 26 and 40, and so on for every month.

The formula for generating random numbers between two numbers m and n is,
(int)Math.floor(m + Math.random() * (n-m+1));

Or you may choose to use the Random Class from the util package.

3. Print the average temperature for each month.
4. Print the hottest day for the entire year, in the following format:
Example: The hottest day was Thursday, July 4. Also, mention what the temperature
Was on this day.
You may assume that January 1 was a Monday.
5. Print the coldest day for the entire year, in the following format:
Example: The coldest day was Tuesday, February 12. Also, mention what the
temperature was on this day. Again, assume that January 1 was a Monday.
6. How many days in the year was it below 330 F and how many more than 750F.

So far i Have this

import java.util.Random;

public class NYCTemp
{

String [] days = {"Sunday","Monday","Tuesday","Wednesday","Thursday ","Friday","Saturday"};

String [] months = {"January","February","March","April","May","June" ,"July","August","September","October","November", "December"};

int [] daysInMonth = {31,29,31,30,31,31,30,31,30,31,30,31};

2. ## Re: Help writing this code

Welcome to the forum! Please read this topic to learn how to post code correctly and other useful info for new members.