Cruz Castillo

Generation

generate functionFri, 05 May 2023

Bot program to count the products bought in the supermarket, with total sum.

void main() { var myProducts = ["Apple:10", "Banana:5", "Milk:20", "Eggs:40"]; var total = 0; for(var product in myProducts) { var name = product.split(":")[0]; var price = int.parse(product.split(":")[1]); total += price; print("$name costs $price"); } print("You have to pay a total of $total"); }

Want to kickstart your project?Use the new AI Studio to create your code