Untitled

 avatar
user_8515817
dart
5 months ago
781 B
4
Indexable
void menuPemesanan() {
  Map<String, double> menu = {
    'Nasi Goreng': 20000.0,
    'Mie Goreng': 15000.0,
    'Ayam Bakar': 25000.0,
    'Teh Manis': 5000.0,
    'Kopi': 10000.0
  };

  double totalHarga = 0.0;

  while (true) {
    print('Menu:');
    menu.forEach((key, value) {
      print('$key: Rp$value');
    });

    stdout.write('Masukkan nama makanan/minuman (atau ketik "selesai" untuk berhenti): ');
    String? input = stdin.readLineSync();

    if (input == null || input.toLowerCase() == 'selesai') {
      break;
    }

    if (menu.containsKey(input)) {
      totalHarga += menu[input]!;
    } else {
      print('Menu tidak tersedia.');
    }
  }

  print('Total harga: Rp$totalHarga');
}

void main() {
  menuPemesanan();
}
Editor is loading...
Leave a Comment