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 5 of 5

Thread: Could use a little help. please and ty!

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Could use a little help. please and ty!

    Hey all. I was sick and missed 2 days of my Java class but i have been trying to catch up. This is my lab assignment that i didnt get till 2 days before it was due... i will post some of my code that i have worked on so far and if anyone could give me pointers because im having trouble understanding java since im mainly a C programmer. Thanks ahead of time to anyone who will help!

    Suppose a company bought an item for certain amount of money and sells it. Do the following:
    Part 1.
    (a) Recognize that this situation describes an entity and give it a name.
    (b) List possible attributes for this entity.
    (c) List possible operations for this entity.
    (d) List two objects for this entity. That is, give two exampls of such a transaction - in terms of their names, the cost of each item, and amount that each is sold for.

    Part 2.
    write a partial class definition to include:
    (a) The name of the class, and
    (b) The variable declarations for the class.

    Part 3. Define an appropriate constructor for the class.

    Part 4.
    (a) Define accessor methods that returns the value prepresented by each variable.
    (b) Include a mutator method that calculates the profit, (assuming profit was made).
    (c) Provide mutator methods to change the name, the purchasing price, and the selling price of the product.

    Part 5 Write a test class that will generate output.

    So far my code is looking like this.
    public class Riotsales 
    {
        private int RP1points;
        private int RP2cost;
        private int RP2points;
        private int RPtotal;
     
        public Riotsales RP1 (int RP1sales, int RP2sales, int RPtotal)
        {    
            RP1sales = 1000;
            RP2sales = 2000;
            RPtotal = RP1sales + RP2sales
        }   
        public int getRP1()
        {
            return RP1sales;
        }
     
        public int getRP2()
        {
            return RP2sales;
        }
     
        public int getRPtotal()
        {
            return RPtotal;
        }

    And here is my Test class which i know is really messed up
    class TestRiotsales
    {
        public static void main (String[] args)
     
    System.out.println(“The total sales for the day are:” );
    System.out.println(“-----------------------------------------------------“);
    System.out.println();
    System.out.println(“1000 Riot points: ” + RP1sales, “ sales.”);
    System.out.println(“2000 Riot points: ” + RP2sales, “ sales.”)
    System.out.println(“Riot Corp.”);
    System.out.println(“--------------------------”);
    System.out.println(“Product: 1000 Riot Points”);
    System.out.println(“Purchase Price: $0.00”);
    System.out.println(“Sale Price: $” + RP2cost,);
    System.out.println(“--------------------------”);
    System.out.println(“Profit: $” + RP2cost,);
    System.out.println();
    System.out.println(“Riot Corp.”);
    System.out.println(“--------------------------”);
    System.out.println(“Product: 2000 Riot Points”);
    System.out.println(“Purchase price: $0.00”);
    System.out.println(“Sale Price: $” + RP1cost,);
    System.out.println(“--------------------------”);
    System.out.println(“Profit: $” + RP2cost,);
    }
    all the 8221's are actually " which is weird that its changing it to numbers

  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Could use a little help. please and ty!

    Welcome wyrven

    Please use code tags when posting code on the forum. See the Announcements page for help.

    Does the code compile?
    Do you have a question about the code or assignment?

  3. The Following User Says Thank You to jps For This Useful Post:

    the wyrven (June 5th, 2013)

  4. #3
    Junior Member
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Could use a little help. please and ty!

    Quote Originally Posted by jps View Post
    Welcome wyrven

    Please use code tags when posting code on the forum. See the Announcements page for help.

    Does the code compile?
    Do you have a question about the code or assignment?
    Oh i see thanks for the announcements tip jps. and its compiling the first part but it is saying my 2nd part is having illegal characters. Also i just figured out i was using the wrong thing for my accessor.
    I changed that but its just all around rough trying to catch up especially when my book is the first edition and the teacher wrote it with his knowledge not the knowledge that you would expect someone new to have.

    Also just to make it a little clearer i would really just like some guidance on what ive done wrong to learn from it because i know i have i just can not pin point it myself.

    And Thanks again!

  5. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Could use a little help. please and ty!

    Quote Originally Posted by the wyrven View Post
    I changed that
    Always post the new version of the code when changes are made

    Quote Originally Posted by the wyrven View Post
    on what ive done wrong
    What makes you think you did something wrong? Is the output incorrect?

  6. #5
    Junior Member
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Could use a little help. please and ty!

    Thanks jps i figured it out finally! it just took a lot of reading and debugging but it eventually compiled properly.