// Name : Matthew Reeves // This is a program to calculate shipping costs import java.util.Scanner; public class mdreeves_Shipping { public static void main ( String args[] ) { Scanner input= new Scanner ( System.in ); int weight, distance, parts; double rate, total; weight=0; distance=0; rate=0; while (distance<1) { System.out.print("How far will you be shipping the package? "); distance=input.nextInt(); } while (weight<1 || weight>65) { System.out.print("How heavy is your package in pounds (1-65)? "); weight=input.nextInt(); } if (weight>=1 && weight <=4) { rate=2.34; } if (weight>=5 && weight <=12) { rate=4.31; } if (weight>=13 && weight <=22) { rate=6.01; } if (weight>=23 && weight <=45) { rate=6.27; } if (weight>=46 && weight <=65) { rate=7.01; } parts=distance/35; if (distance%35!=0) { parts++; } total=parts*rate; System.out.print("The shipping rate is $"+rate+" per 35 miles.\n"); System.out.printf("The total cost to ship your %d pound package %d miles is $%.2f.\n", weight, distance, total); } }