int packaging = 2;
// Next Day Priority(1) || Next Day Standard(2) || 2-Day(3)
int service = 3;
// Weight
float weight = 3 ;
float charge;
void setup() {
size(300, 300);
}
void draw() {
background(255);
fill(0);
textSize(25);
text("DELIVERY SERVICE", 45, 20);
textSize(15);
text("Types of packaging", 10, 60);
text("letter || box", 10, 80);
text("Types of service", 10, 120);
textSize(12);
text("Next Day Priority || Next Day Standard || 2-Day", 10, 140);
//call funftion
textSize(20);
calculate_charge();
text("CHARGE : $ "+charge, 20, 260);
}
void calculate_charge() {
// *****letter***** //
if (packaging == 1) {
text("PACKAGING : letter", 20, 180);
text("WEIGHT : "+weight+" oz", 20, 240);
// *****Next Day Priority***** //
if (service == 1) {
text("SERVICE : Next Day Priority", 20, 200);
if (weight >= 8) {
charge = 12;
} else {
charge = 0;
}
}
// *****Next Day Standard***** //
if (service == 2) {
text("SERVICE : Next Day Standard", 20, 200);
if (weight >= 8) {
charge = 10.5;
} else {
charge = 0;
}
}
// *****2-Day***** //
if (service == 3) {
text("SERVICE : 2-Day", 20, 200);
text("Not available", 20, 290);
}
}
// *****box***** //
if (packaging == 2) {
text("PACKAGING : box", 20, 180);
text("WEIGHT : "+weight+" pound", 20, 240);
// *****Next Day Priority***** //
if (service == 1) {
text("SERVICE : Next Day Priority", 20, 200);
if (weight == 1) {
charge = 15.75;
} else if (weight>=2) {
charge = 15.75+((weight-1)*1.25);
} else {
charge = 0;
}
}
// *****Next Day Standard***** //
if (service == 2) {
text("SERVICE : Next Day Standard", 20, 200);
if (weight == 1) {
charge = 13.75;
} else if (weight>=2) {
charge = 13.75+((weight-1)*1);
} else {
charge = 0;
}
}
// *****2-Day***** //
if (service == 3) {
text("SERVICE : 2-Day", 20, 200);
if (weight == 1) {
charge = 7;
} else if (weight>=2) {
charge = 7+((weight-1)*0.5);
} else {
charge = 0;
}
}
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น