Results 1 to 2 of 2
  1. #1
    snobbysteven is offline Member
    Join Date
    Oct 2012
    Posts
    17
    Rep Power
    0

    Unhappy Help with assignment

    Here is the Assignment:


    Call the class described in the assignment GradeDistributionID0000.java

    Write a program Ass5ID0000.java ("0000" is your ID) that

    creates an instance of GradeDistribution

    tests all of the methods from your implementation of the GradeDistribution class.

    None of the methods from the GradeDistribution class should prompt a user for input.

    All prompting of a user should be done by the Ass5ID0000.java program which should use the set methods from the GradeDistribution class to put data into a GradeDistributionID0000 object.

    Your class should have the following methods.
    setNumberOfAs()
    setNumberOfBs()
    setNumberOfCs()
    setNumberOfDs()
    setNumberOfFs()
    getNumberOfAs()
    getNumberOfBs()
    getNumberOfCs()
    getNumberOfDs()
    getNumberOfFs()
    getTotalNumberOfGrades()
    getPerCentA()
    getPerCentB()
    getPerCentC()
    getPerCentD()
    getPerCentF()
    drawGraph()


    ------------------------------------

    heres what I have so far, but im not sure how to bring the methods and statements from Grade over to the Ass5ID side.

    Java Code:
    //Ass5ID0000
    //Main method
    
    import java.util.*;
    
    public class Ass5ID0000
    {
      public static void main(String[] args)
      {
        
       Scanner keyboard = new Scanner(System.in);
       
       System.out.println("how many A's were given?");
         GradeDistribution.A = keyboard.nextint();
         
      }
    }
    Java Code:
    //Assignment 6
    //Grade Distribution
    
    
    public class GradeDistribution
    {
        
        public int A,B,C,D,F;
        
        public void setNumberOfAs()
        {
          return;
        }
        
        public void setNumberOfBs()
        {
          return;
        }
        
        public void setNumberOfCs()
        {
          return;
        }
        
        public void setNumberOfDs()
        {
          return;
        }
        
        public void setNumberOfFs()
        {
          return;
        }
        
        public int getNumberOfAs()
        {
          return A;
        }
        public int getNumberOfBs()
        {
          return B;
        }
        public int getNumberOfCs()
        {
          return C;
        }
        public int getNumberOfDs()
        {
          return D;
        }
        public int getNumberOfFs()
        {
          return F;
        }
        public int getTotalNumberOfGrades()
        {
          return A+B+C+D+F;
        }
        
        
        public int getPerCentA()
        {
          return (A/(A+B+C+D+F)*100);
        }
        public int getPerCentB()
        {
          return (B/(A+B+C+D+F)*100);
        }
        public int getPerCentC()
        {
          return (C/(A+B+C+D+F)*100);
        }
        public int getPerCentD()
        {
          return (D/(A+B+C+D+F)*100);
        }
        public int getPerCentF()
        {
          return (F/(A+B+C+D+F)*100);
        }
    }
    Last edited by pbrockway2; 10-20-2012 at 07:19 AM. Reason: code tags added

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,568
    Rep Power
    12

    Default Re: Help with assignment

    Hi snobbysteven, welcome to the forums! I have added "code" tags to your post. The idea is that you put [code] at the start of a section of code and [/code] so that the code appears correctly formatted and readable.

    Write a program Ass5ID0000.java ("0000" is your ID) that

    creates an instance of GradeDistribution

    ...
    You haven't done that. That is to say your main() method does not use the "new" operator to create an instance of GradeDistribution. It's the first thing you were told to do and it should probably be the first line of the main() method.

Similar Threads

  1. Need Help with assignment
    By Resurgam in forum New To Java
    Replies: 5
    Last Post: 02-22-2012, 10:10 PM
  2. Need help with assignment.
    By smileybear33 in forum New To Java
    Replies: 2
    Last Post: 04-26-2011, 04:47 AM
  3. Help with an assignment
    By aqeel2010 in forum New To Java
    Replies: 5
    Last Post: 01-14-2011, 10:04 AM
  4. assignment
    By mr.othman in forum New To Java
    Replies: 4
    Last Post: 12-03-2010, 03:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •