1. Home
  2. /
  3. Simula
  4. /
  5. Shopping Cart

Shopping Cart - Simula Typing CST Test

Loading…

Shopping Cart — Simula Code

Adds and removes items in a shopping cart with total cost.

BEGIN
	ARRAY cart[10]; ARRAY prices[10]; INTEGER count;
	count := 0;
	PROCEDURE addItem(item, price);
	BEGIN
		cart[count] := item; prices[count] := price; count := count + 1;
	END addItem;

	PROCEDURE removeItem(idx);
	BEGIN
		INTEGER i;
		FOR i := idx STEP 1 UNTIL count-2 DO cart[i] := cart[i+1]; prices[i] := prices[i+1] END;
		count := count - 1;
	END removeItem;

	addItem("Apple",2);
	addItem("Banana",3);
	removeItem(0);
END

Simula Language Guide

Simula is a high-level, statically typed programming language designed for simulation and object-oriented programming. It introduced the concept of classes, objects, and inheritance, laying the foundation for modern object-oriented languages like C++ and Java.

Primary Use Cases

  • ▸Discrete event simulation
  • ▸Teaching object-oriented programming
  • ▸Modeling complex systems
  • ▸Research in programming languages
  • ▸Historical study of software engineering paradigms

Notable Features

  • ▸Classes and objects for abstraction
  • ▸Inheritance for code reuse
  • ▸Coroutines for concurrent simulation
  • ▸Strong static typing
  • ▸Integrated simulation constructs (processes, events, queues)

Origin & Creator

Simula was developed in the 1960s by Ole-Johan Dahl and Kristen Nygaard at the Norwegian Computing Center (Norsk Regnesentral) to support simulation of complex systems.

Industrial Note

Simula is primarily used in academia and research, particularly for simulation modeling and teaching object-oriented programming concepts.

More Simula Typing Exercises

Simula Counter and Theme ToggleSimula Random Number GeneratorSimula Todo ListSimula Dice RollerSimula Countdown TimerSimula Prime CheckerSimula Temperature ConverterSimula Name GreetingSimula Stopwatch

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher