int space = 50;
void setup() {
size(650, 300);
int x =50, y =50;
int packageType = 2;
int serviceType = 2;
float weight = 7.99;
fill(#00FFFF);
textSize(40);
text("Expressimo Delivery Service", x, y);
charge(x+space, y+space, packageType, serviceType, weight);
}
void charge(int x, int y, int package_t, int service_t, float weight) {
float cost = 0;
fill(#00FF00);
textSize(25);
if (package_t == 1) {
text("Package Type : LETTER", x, y);
} else if (package_t == 2) {
text("Package Type : BOX", x, y);
} else {
text("Package Type : ERROR", x, y);
}
if (service_t == 1) {
text("Service Type : Next day Priority", x, y+space);
} else if (service_t == 2) {
text("Service Type : Next day Standard", x, y+space);
} else if (service_t == 3) {
text("Service Type : Two-days", x, y+space);
} else {
text("Service : ERROR", x, y+space);
}
if (package_t == 1) {
text("Weight : "+weight+" Oz", x, y+space*2);
if (service_t == 1 && weight <= 8) {
cost = 12;
}
if (service_t == 2 && weight <= 8) {
cost = 10.5;
}
if (service_t >= 3 || weight > 8) {
cost = 0;
text("Charge : $"+cost+" (No Services)", x, y+space*3);
}
}
if (package_t == 2) {
text("Weight : "+weight+" Pound", x, y+space*2);
if (service_t == 1) {
if (weight <= 1) cost = 15.75;
else if (weight > 1) {
cost = cal_service1(weight);
}
} else if (service_t == 2) {
if (weight <= 1) cost = 13.75;
else if (weight > 1) {
cost = cal_service2(weight);
}
} else if (service_t == 3) {
if (weight <= 1) cost = 7.00;
else if (weight > 1) {
cost = cal_service3(weight);
}
}
}
text("Charge : $"+cost, x, y+space*3);
}
float cal_service1(float weight) {
float priority_charge;
float firstCharge = 15.75;
priority_charge = firstCharge + ((weight-1)*1.25);
return priority_charge;
}
float cal_service2(float weight) {
float standard_charge;
float firstCharge = 13.75;
standard_charge = firstCharge + ((weight-1)*1);
return standard_charge;
}
float cal_service3(float weight) {
float twodays_charge;
float firstCharge = 7.00;
twodays_charge = firstCharge + ((weight-1)*0.5);
return twodays_charge;
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น