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


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Help writing this code

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default 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.

    Please post your code correctly.

    I was just recommending to someone else that they write small bits of code, test thoroughly, and then repeat. I'm encouraged that you're using that approach. Since you didn't post all of your code, please do when you edit your post, and then ask specific questions about what you need help with.

Similar Threads

  1. Help needed for writing a code
    By ahanf in forum Object Oriented Programming
    Replies: 9
    Last Post: July 9th, 2012, 07:06 AM
  2. Need Help Writing Exception code.
    By USCPaddler in forum Exceptions
    Replies: 4
    Last Post: November 10th, 2011, 06:45 PM
  3. writing java code help
    By jaisan72980 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: February 12th, 2011, 03:39 PM
  4. Trouble writing some code...help?
    By bChEos in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: February 7th, 2010, 08:54 PM
  5. Help writing some Scanner code
    By bChEos in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: February 3rd, 2010, 04:27 AM