Java Programming Write a program that will calculate the shi
Java Programming
Write a program that will calculate the shipping charge for a package, based on its weight. Display the customer\'s name, a package id, the weight (in ounces) and the shipping charge ($2.00 / pound) each on separate lines. Line up the answers vertically using the correct escape characters.
example:
Name: Jared Weaver
Package ID: 123456
Weight: 17 oz.
Shipping Costs: 2.04
Solution
/*
ShippingCost.java
*/
import java.util.Scanner;
public class ShippingCost
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println(\"Enter Customer Name: \");
String name = sc.nextLine();
System.out.println(\"Enter Package ID: \");
String packageID = sc.nextLine();
System.out.println(\"Enter the Weight(in ounces): \");
double weight = sc.nextDouble();
// convert to pound
weight = (weight*0.0625);
double charge = (weight * 2.0);
System.out.println(\"\ Name:\\t\\t \" + name);
System.out.println(\"Package ID:\\t \" + packageID);
System.out.println(\"Weight:\\t\\t \" + weight + \" oz.\");
System.out.println(\"Shipping Cost:\\t \" + charge);
}
}
/*
output:
Enter Customer Name:
alex hales
Enter Package ID:
123
Enter the Weight(in ounces):
17
Name: alex hales
Package ID: 123
Weight: 1.0625 oz.
Shipping Cost: 2.125
*/

