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

Thread: Can someone help me with my Computer Science homework :)

  1. #1
    Junior Member surfelijo's Avatar
    Join Date
    Feb 2013
    Location
    Fallbrook, CA
    Posts
    14
    My Mood
    Nerdy
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Talking Can someone help me with my Computer Science homework :)

    This is what my professor send me

    PDF
    HTML Code:
    [ATTACH]1975[/ATTACH]
    " In this lab you will create a program that computes charges to ship a package with Super Fast Diego
    Company. Using Assignment #3 and your Common Classes:

    Class ShippingCharges
    Attributes:
    int packageID;
    double weight;
    double distance;
    double charges = 0.00f;
    Customer customerShip;
    Customer customerReceive;
    Include  public void printInvoice()

    Class Customer
    Name name;
    Address address;
    Phone phone;
    Example of a ShippingChgDriver
    public class ShippingChgDriver
    {
    public static void main()
    {
    System.out.println("Enter a package to be shipped");
    ShippingCharges package1 = new ShippingCharges();
    package1.printInvoice();
    } // main()
    } // end ShippingChgDriver"

    /**
     * Assignment 3
     *
     * Jared Wines
     * CS 111
     */
     
     
     //Class Customer
     
    public class CommonClasses
    {
     
    	Name name;
    	Address address;
    	Phone phone;
     
     
      			public static void main(String[] args) {
    {
    			System.out.println("Enter a package to be shipped");
    			ShippingCharges package1 = new ShippingCharges();
     
    } // main()
    } // end ShippingChgDriver
    }


    /**
     * Assignment 3
     *
     * Jared Wines
     * CS 111
     */
     
     
     //Class ShippingCharges
     
     import java.util.Scanner;
    public class Assignment3
    {
     
        public static void main(String[] args) {
     
     
        	// Problem 1
     
        	 Scanner keyboard = new Scanner(System.in);
     
        	double weight = 0.0;  
        	double distance = 0.0 ;  
        	double charge = 0.0;  
     
        	System.out.println("Please enter the weight of you package");
        	weight = keyboard.nextDouble();
        	System.out.println("please enter the distance");
        	distance = keyboard.nextDouble();
     
        	int distanceFactor = (int) (distance / 500);
        	System.out.println(distanceFactor);
        	if ( distance % 500 > 0.0)
        	   distanceFactor++;
     
        	System.out.println(distanceFactor);
     
        	if (weight <= 2.0)
        		charge = 1.1 * distanceFactor;
        	else if (weight > 2.0 && weight <= 6.0)
        		charge = 2.2 * distanceFactor ;
        	else if (weight > 6.0 && weight <= 10.0)
        		charge = 3.7 * distanceFactor;
        	else if (weight > 10.0)
        		charge = 4.8 * distanceFactor;
     
     
        	System.out.println("Distance = " + distance + " weight = " + weight + " charges = " + charge);	
     
     
        }//end class
     
    }//end main


    import java.util.Scanner;
     
    public class Phone
    {
        String home;
        String cell;
        String work;
        String workExt;
     
        public Phone()
        {
            Scanner inPhone = new Scanner(System.in);
            System.out.println("Enter a home phone number \"area xxx xxxx\" or return for no number");
            home = inPhone.nextLine();
            System.out.println("Enter a cell phone number \"area xxx xxxx\" or return for no number");
            cell = inPhone.nextLine();
            System.out.println("Enter a work phone number \"area xxx xxxx\" or return for no number");
            work = inPhone.nextLine();
            if (work.equals(" "))
            {
                 // there is a work extension
            }
            else
            {
                System.out.println("Enter work extension number or return for no number");
                workExt = inPhone.nextLine();
            }
         }
         public Phone(char whatNum, String newNumber)
         {
             if (whatNum == 'H' || whatNum == 'h')
             {
                 home = newNumber;
             }
             else if (whatNum == 'C' || whatNum == 'c')
             {
                 cell = newNumber;
             }
             else if (whatNum == 'W' || whatNum == 'w')
             {
                 work = newNumber;
             }
         }
        public void setHomePhoneNumber(String newNumber)
        {
            home = newNumber;
        }
        public String getHomePhoneNumber()
        {
            return home;
        }
        public void setCellPhoneNumber(String newNumber)
        {
            cell = newNumber;
        }
        public String getCellPhoneNumber()
        {
            return cell;
        }
        public void setWorkPhoneNumber(String newNumber)
        {
            work = newNumber;
        }
        public String getWorkPhoneNumber()
        {
            return work;
        }
        public void setWorkExtPhoneNumber(String newNumber)
        {
            workExt = newNumber;
        }
        public String getWorkExtPhoneNumber()
        {
            return workExt;
        } 
     
    }// end class Phone


    import java.util.Scanner;
     
    public class Address
    {
        String street;
        String city;
        String state;
        String zipCode;
     
        public Address()
        {
            Scanner inAddress = new Scanner(System.in);
            System.out.println("Enter street address");
            street = inAddress.nextLine();
            System.out.println("Enter city");
            city = inAddress.nextLine();
            System.out.println("Enter state");
            state = inAddress.nextLine();
            System.out.println("Enter zip code");
            zipCode = inAddress.nextLine();
        }
        public Address(String newStreet, String newCity, String newState, String newZip)
        {
            street = newStreet;
            state = newState;
            city = newCity;
            zipCode = newZip;
        }
        public void setStreet(String newStreet)
        {
            street = newStreet;
        }
        public String getStreet()
        {
            return street;
        }
        public void setCity(String newCity)
        {
            city = newCity;
        }
        public String getCity()
        {
            return city;
        }
        public void setState(String newState)
        {
            state = newState;
        }
        public String getState()
        {
            return state;
        }
        public void setZipCode(String newZip)
        {
            zipCode = newZip;
        }
        public String getZipCode()
        {
            return zipCode;
        }
        public String toString()
        {
     
            return street + " " + city + " " + state + " " + zipCode;
        }
     
     
    } // end class Address


    import java.util.Scanner;
     
    public class Name 
    {
      String firstName;
      String lastName;
      String middleName;
     
      // constructors methods
      public Name()
      {
        Scanner keyboard = new Scanner(System.in);
        System.out.println("enter person's firstname middlename lastname");
        firstName = keyboard.next();
        middleName = keyboard.next();
        lastName = keyboard.nextLine();
     
      }
      public Name(String newFirst, String newMiddle, String newLast)
      {
      	firstName = newFirst;
      	middleName = newMiddle;
      	lastName = newLast;
      }
     
      // setters & getters
      public String getFirstName()
      {
      	return firstName;
      }
      public void setFirstName(String newFirst)
      {
      	firstName = newFirst;
      }
      public String getMiddleName()
      {
      	return middleName;
      }
      public void setMiddleName(String newMiddle)
      {
      	middleName = newMiddle;
      }
      public String getLastName()
      {
      	return lastName;
      }
      public void setLastName(String newLast)
      {
      	lastName = newLast;
      }
     
      public String toString()
      {
      	return firstName + " " + middleName + " " + lastName;
      }
     
     
     
      }// end Name class


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,152
    Thanks
    49
    Thanked 2,158 Times in 2,131 Posts

    Default Re: Can someone help me with my Computer Science homework :)

    Do you have any specific questions about your assignment?
    Please post any questions about problems you are having.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member surfelijo's Avatar
    Join Date
    Feb 2013
    Location
    Fallbrook, CA
    Posts
    14
    My Mood
    Nerdy
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Can someone help me with my Computer Science homework :)

    I dont fully understand what i need to do. Thank you

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,152
    Thanks
    49
    Thanked 2,158 Times in 2,131 Posts

    Default Re: Can someone help me with my Computer Science homework :)

    Read the assignment and ask your instructor if you need further instructions about it.

    I dont fully understand
    Work on the parts you do understand and ask some specific questions about the other parts.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Working on a phdgets Project for Computer Science Need some Help.
    By Tallonejosh in forum What's Wrong With My Code?
    Replies: 21
    Last Post: April 25th, 2012, 08:39 AM
  2. AP computer science questions
    By svo in forum Java Theory & Questions
    Replies: 1
    Last Post: April 7th, 2012, 02:24 PM
  3. AP computer science questions
    By svo in forum Java Theory & Questions
    Replies: 1
    Last Post: April 6th, 2012, 11:32 PM
  4. need help in AP Computer Science!
    By eechord in forum Member Introductions
    Replies: 3
    Last Post: October 7th, 2011, 09:57 AM
  5. computer science help
    By hairyjewbear in forum Algorithms & Recursion
    Replies: 6
    Last Post: November 4th, 2010, 04:05 PM

Tags for this Thread