alert()pops up a window with a message given by whatever string you put between the ()s. Try entering
prompt(). You give it a message indicating to the user what input is supposed to be provided, and
prompt( stringLiteral-Variable )pops up a window with the message and an input box. Whatever string gets entered on that line gets returned as the value of the
//until the next newline character is ignored by the interpreter, and so we use
//to write comments.
Below is a simple program that gets the users height and weight and returns to the user what his weight would be if he were 25 feet tall. Play with it, understand it, and see if you can modify it so that it asks the user for a target height (in feet) rather than always using 25.
totalkeeps a running total of the cost, which gets updated as the user orders a certain number of burgers, then a certain number of fries, then a certain number of drinks. An interesting twist is to ask for the program to repeat the user's order before giving the total. We can accomplish this by keeping a running list of what gets ordered. The variable
totalis a number, and is initially zero to indicate that, at the beginning, the user hasn't yet ordered anything. To keep a running list of what's been ordered, we need a variable (we'll call it
order) of type
string. Initially, since nothing has been ordered, that string will be the empty string, i.e.
"". In this second version of the program, all three variables —
order— are constantly being assigned new values.
1974: DoD is using 450 different programming languages, spending $3 billion/year on software maintenance ($14 billion in 2012 dollars). A major part of "software maintenance" is fixing BUGS!. A search begins for an existing language most suited to DoD requirements ...
1977: No existing programming language is suitable. DoD solicits proposals for a language appropriate for embedded computer applications (i.e., command and control, communications, avionics, shipboard, test equipment, software development and maintenance, and support applications). ["Steelman"]
1980: DoD completes specification of the "Ada" language and subsequently mandates its use.
Here's Ada code essentially equivalent to
prompt( "Hello, World!" );
with Text_IO; use Text_IO;
procedure Hello is
1996: DoD now using only 37 different programming languages. Much new code is being written in ADA, which is easier (thus less costly) to maintain: Ada was designed to be less prone to the kind of bugs that make software vulnerable to attack.
Today: Ada code is executing on US Navy systems such as the Aegis Weapon System, SSN-21 AN/BSY-2 Submarine Combat Control System, V-22 Osprey, AGM-114 Hellfire missile, CH46 Cockpit Control System, Tomahawk missiles, MK 41 Vertical Launch System.