This is what my professor send me
" In this lab you will create a program that computes charges to ship a package with Super Fast DiegoHTML Code:[ATTACH]1975[/ATTACH]
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