Created with <3 with dartpad.dev.
Last active
November 24, 2023 07:57
-
-
Save Vanns35/6cfbde0f40f1e414a937cfd69bc657fa to your computer and use it in GitHub Desktop.
windy-waterfall-5497
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
int quantityModelX = 8; | |
double priceModelX = 50000.00; | |
int quantityModelZ = 10; | |
double priceModelZ = 60000.00; | |
String customerAccountNo = "1025496"; | |
double customerAccountBalance = 80000.00; | |
String model = "Model-X"; | |
int shippingDistance = 25; | |
if(customerAccountNo.length > 6 && customerAccountNo.startsWith("10")) { | |
if(model == "Model-X" || model == "Model-Z") { | |
int selectedQuantity = (model == "Model-X") ? quantityModelX : quantityModelX; | |
if(selectedQuantity > 0) { | |
double gstRate = 0.24; | |
double gstAmount = (model == "Model-X") ? priceModelX * gstRate : priceModelZ * gstRate; | |
double shipmentFee = 25.0; | |
if(shippingDistance > 50) { | |
shipmentFee = shipmentFee + (shippingDistance - 50) * 0.35; | |
} | |
double billAmount = (model == "Model-X") ? priceModelX + gstAmount + shipmentFee : priceModelZ + gstAmount + shipmentFee; | |
if(customerAccountBalance >= billAmount) { | |
(model == "Model-X") ? quantityModelX-- : quantityModelZ--; | |
customerAccountBalance = customerAccountBalance - billAmount; | |
print("Purchase is successful by Customer $customerAccountNo for Model $model at Price $billAmount"); | |
print("Remaining quantity for $model: ${(model == "Model-X") ? quantityModelX : quantityModelZ}"); | |
print("Remaining account balance for Customer $customerAccountNo is $customerAccountBalance"); | |
} else { | |
print("Customer have insufficient amount"); | |
} | |
} else { | |
print("No available cars for selected Model."); | |
} | |
} else { | |
print("Invalid Model Selection"); | |
} | |
} else { | |
print("Customer number is Invalid."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment