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: Working with Arrays

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    23
    My Mood
    Daring
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Working with Arrays



    I'm having a problem with one part of this assignment, the instruction is this "Add a method transaction which takes two int parameters, daynum and amount. daynum is the day of the month, and amount is an amount of money made or lost for a transaction on that day. (hint: days of the month are numbered starting from 1, arrays arent; think about how to handle this)." this is what I have so far
     public class MonthlyRecord {
    //instance variables
        private String month;
        private double[] moneyDaily;
     
    //default constructor
        public MonthlyRecord() {
            month = "January";
            moneyDaily = new double[31];
        }
    //accessor for monthlyRecord
        public String getMonth() {
            return month;
        }
    //mutator for monthlyRecord
        public void setMonth(String v) {
            month = v;
        }
    //constructor with parameters from whatever is calling it
        public MonthlyRecord(String b, int x) {
            month = b;
            moneyDaily = new double[x];
        }
     /*Add a method transaction which takes two
      * int parameters, daynum and amount.  
      * daynum is the day of the month, 
      * and amount is an amount of money made or 
      * lost for a transaction on that day*/   
     
     
        public void Transaction(int dayNum, int amount) {
       dayNum = 0;
       amount = 0;


    It could just be because my brain feels a lttle fried for some reason, but what am I missing here to ensure this is done correctly? Thx in advance!


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Working with Arrays

    First problem I see is that the method is incorrectly named. Java is case sensitive. T is not the same as t

    What is the method supposed to do with the values passed in its args?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Arrays
    By oonagh in forum What's Wrong With My Code?
    Replies: 4
    Last Post: December 7th, 2012, 10:03 AM
  2. Help with Arrays
    By xdx in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 10th, 2012, 12:39 AM
  3. Need Help with Arrays
    By zennbang in forum Object Oriented Programming
    Replies: 3
    Last Post: July 31st, 2011, 06:41 AM
  4. Replies: 4
    Last Post: January 27th, 2009, 12:03 AM

Tags for this Thread