/**
Jennierose
Rizzo, Weymouth High School
Intermediate
5, Contest 1
ACSL
Post Office
This
program is designed to determine the postage for entered mail depending on
the
class and weight of a piece of mail.
**/
public
class ACSLPostOffice
{
public double length;
public double width;
public double thickness;
public double weight;
public ACSLPostOffice(double l,
double w, double t, double wt)
{
length
= l;
width
= w;
thickness
= t;
weight
= wt;
}
public double getLength()
{
return
length;
}
public double getWidth()
{
return
width;
}
public double getThickness()
{
return
thickness;
}
public double getWeight()
{
return
weight;
}
public double determinePostage()
{
double
price = 0.0;
double
L = getLength();
double
W = getWidth();
double
T = getThickness();
double
WT = getWeight();
//Regular
Post Card
if((L
>= 3.5 && L <= 4.25) && (W >= 3.5 && W <=
6.0) && (T >= .007 && T <= .016))
{
price = .20;
for(double x = WT; x > .0625;
x -= .0625)
price
+= .20;
}
//Large
Post Card
else
if((L >= 4.25 && L <= 6.0) && (W >= 6.0 && W
<= 11.5) && (T >= .007 && T <= .016))
{
price = .30;
for(double x = WT; x > .0625;
x -= .0625)
price
+= .30;
}
//Envelope
else
if((L >= 3.5 && L <= 6.125) && (W >= 5.0 && W
<= 11.5) && (T >= .016 && T <= .25))
{
price = .47;
for(double x = WT; x > .0625;
x -= .0625)
price
+= .47;
}
//Large
Envelope
else
if((L >= 6.125 && L <= 24.0) && (W >= 11.0 &&
W <= 18.00) && (T >= .25 && T <= .5))
{
price = .56;
for(double x = WT; x > .0625;
x -= .0625)
price
+= .56;
}
//Package
else
if((L > 24 && W > 18 && T > .5) && (L + (W*2 +
T*2) <= 84))
{
price = 1.50;
for(double x = WT; x > .5; x
-= .5)
price
+= 1.50;
}
//Large
Package
else
if((L + (W*2 + T*2) > 84) && (L + (W*2 + T*2) <= 130))
{
price = 1.75;
for(double x = WT; x > .5; x
-= .5)
price
+= 1.75;
}
//Unmailable
else
price = 0;
return
price;
}
}