DECLARE SUB levelmenu () DECLARE SUB equation () DECLARE SUB PrintEquation (eq!) DECLARE FUNCTION CalcEquation! (equation!, solveFor!, a!, b!, c!, d!, constant!) DECLARE SUB definition (array1() AS STRING, array2() AS STRING, term AS STRING, nterms) DECLARE SUB qmark (ans!, nans!) DECLARE SUB mark (choice!, ans!) DECLARE SUB question () DECLARE SUB pause () DECLARE SUB mainmenu () DECLARE SUB mainhelp () DECLARE SUB categorymenu () DECLARE SUB question () DECLARE SUB match (qarray() AS STRING, aarray() AS STRING, narray!, nans!) DECLARE SUB number (qarray() AS STRING, aarray!(), nques!) DECLARE FUNCTION irand! (i!) DIM SHARED correct, tries, nchoices nchoices = 4 DIM SHARED progname AS STRING progname = "Physics Quiz Program" ' Question Categories DIM SHARED category, ncat ncat = 15 DIM SHARED CatName(ncat) AS STRING DATA "Measuring Instruments", "Circuit Components", "Optical Instruments", "Musical Instruments", "Electrical Appliances", "Formulas", "Quantities", "Prefixes", "Constants", "Experiment Terms", "Electromagnetic Radiation", "Energy Sources", "Energy Forms", "Miscellaneous Terms", "Equations" FOR i = 1 TO ncat READ CatName(i) NEXT i ' Level DIM SHARED level, nlevels level = 0 'random nlevels = 3 DIM SHARED LevelName(nlevels) AS STRING DATA "IGCSE (Core)", "IGCSE (Extended)", "HIGCSE" FOR i = 1 TO nlevels READ LevelName(i) NEXT i '' Instruments ' Measuring Instruments DIM SHARED nInstMeas nInstMeas = 23 DIM SHARED InstMeasName(nInstMeas) AS STRING DIM SHARED InstMeasDesc(nInstMeas) AS STRING 'General DATA "protractor", "measures angles" DATA "set square", "produces right angles" DATA "drawing compass", "draws circles and arcs" 'Length DATA "ruler", "measures straight lengths up to 30 cm or 1 m (accuracy 1 mm)" DATA "measuring tape", "measures curved lengths up to 1 or 2 m (accuracy 1 mm)" DATA "vernier calipers", "measures very small lengths (accuracy less than 1 mm)" 'Time DATA "stop watch", "measures time (accuracy 0.01 s); often used at athletic events" DATA "electronic timer", "measures time (accuracy 1 ms); used in science laboratories" DATA "clock", "measures time (accuracy 1 s or 1 min); often hangs on a wall" DATA "watch", "measures time (accuracy 1 s or 1 min); often worn on the wrist" DATA "hourglass", "measures time (not very accurate); glass container filled with sand" 'Speed DATA "speedometer", "measures speed of car, bicycle, or airplane" 'Mass, Weight, and Force DATA "triple beam balance", "measures mass by using three movable masses" DATA "spring scale", "measures weight by pulling a coil of metal" DATA "bathroom scale", "measures mass of a person" 'Temperature DATA "thermometer", "measures temperature by thermal expansion of a liquid" DATA "thermocouple", "measures temperature difference by producing electric current in wires" 'Electricity and Magnetism DATA "compass", "measures geographic direction using the earth's magnetic field and a small pivoting magnet" DATA "ammeter", "measures current" DATA "galvanometer", "measures very small current changes" DATA "voltmeter", "measures EMF (potential difference)" DATA "multimeter", "measures large range of voltages and currents" DATA "oscilloscope", "displays electronic signals on a cathode ray tube screen" FOR i = 1 TO nInstMeas READ InstMeasName(i), InstMeasDesc(i) NEXT i ' Circuit Components DIM SHARED nInstCirc nInstCirc = 19 DIM SHARED InstCircName(nInstCirc) AS STRING DIM SHARED InstCircDesc(nInstCirc) AS STRING DATA "switch", "turns the flow of electric current on or off" DATA "resistor", "reduces the flow of electric current" DATA "cell", "single source of direct current" DATA "battery", "more than one cell in series" DATA "potentiometer", "variable (changing) resistor" DATA "ammeter", "measures current" DATA "galvanometer", "measures very small current changes" DATA "voltmeter", "measures EMF (potential difference)" DATA "solenoid", "coil of wire which generates a magnetic field when current flows through it" DATA "bell", "a metal hammer strikes a metal circle and makes a ringing sound" DATA "fuse", "safety device that burns if too much current goes through it" DATA "relay", "a safe high-voltage switch which uses magnetism" DATA "lamp", "a round glass bulb or chamber containing a metal filament that produces light when heated" DATA "wire", "a long, thin piece of metal often used to conduct electricity" DATA "capacitor", "two flat, parallel plates used to store charge" DATA "diode", "allows current to flow one way but not the other" DATA "transistor", "an electronic switch controlled by current through a third wire" DATA "thermistor", "a heat-sensitive variable resistor" DATA "transformer", "two coils of wire and a soft iron core that change voltage and current" FOR i = 1 TO nInstCirc READ InstCircName(i), InstCircDesc(i) NEXT i ' Optical Instruments DIM SHARED nInstOpt nInstOpt = 9 DIM SHARED InstOptName(nInstOpt) AS STRING DIM SHARED InstOptDesc(nInstOpt) AS STRING DATA "binoculars", "two sets of lenses used to view distant objects with both eyes" DATA "telescope", "lenses and mirrors used to view objects in space" DATA "microscope", "lenses used to view small objects" DATA "camera", "lenses and/or holes used to make a picture on film" DATA "projector", "lenses used to focus an image of a slide or transparency on a screen" DATA "eye", "body organ used to focus light and send information to the brain" DATA "glasses", "lenses used to improve eye vision" DATA "magnifying glass", "lens used to see an enlarged image of an object" DATA "photocopier", "uses light and static electric charge to make duplicates of a paper" FOR i = 1 TO nInstOpt READ InstOptName(i), InstOptDesc(i) NEXT i ' Musical Instruments DIM SHARED nInstMusic nInstMusic = 12 DIM SHARED InstMusicName(nInstMusic) AS STRING DIM SHARED InstMusicDesc(nInstMusic) AS STRING DATA "drum", "a cylinder is covered with a skin at each end which is struck and vibrates" DATA "piano", "pressing a key makes a hammer hit a wire" DATA "guitar", "metal wires are pulled (plucked) and amplified with a wood box" DATA "flute", "air is blown through a hole in a stick and comes out other holes" DATA "xylophone", "pieces of wood or metal of different lengths are struck with a hammer" DATA "violin", "metal wires are vibrated with a string held by a long wood bow" DATA "trumpet", "air is blown into a small brass tube and comes out a larger tube" DATA "tuning fork", "a metal stick with two arms makes a clear sound when struck" DATA "pan pipes", "blowing into wood or metal tubes makes different sounds" DATA "whistle", "high-pitch sound is made by blowing into a small tube; often used at athletic contests" DATA "bell", "a metal hammer strikes a metal circle and makes a ringing sound" DATA "gong", "a large metal plate is struck and makes a low ringing sound" FOR i = 1 TO nInstMusic READ InstMusicName(i), InstMusicDesc(i) NEXT i ' Electrical Appliances and Tools DIM SHARED nInstElec nInstElec = 22 DIM SHARED InstElecName(nInstElec) AS STRING DIM SHARED InstElecDesc(nInstElec) AS STRING 'Tools DATA "drill", "turning stick which makes holes in wood or metal" DATA "saw", "machine with a blade to cut wood or metal" 'Home Appliances DATA "kettle", "heats water for coffee or tea" DATA "refridgerator", "electric box to keep food cool" DATA "washing machine", "metal box that washes clothes" DATA "dryer", "metal box that removes water from clothes" DATA "fan", "turning blades blow air and make people feel cooler" DATA "lamp", "a round glass bulb or chamber containing a metal filament that produces light when heated" DATA "vacuum cleaner", "removes dirt from carpets by sweeping and taking in air" DATA "lawn mower", "cuts grass" DATA "water heater", "makes showers more comfortable and dishes cleaner" DATA "heater", "makes a room warmer on a cold day" DATA "air conditioner", "makes a room cooler on a hot day" DATA "stove", "cooks food" DATA "iron", "removes wrinkles from clothes to make them look good" 'Electronic Equipment DATA "telephone", "allows two people to talk over a long distance" DATA "computer", "smart machine that can calculate, display pictures and make letters" DATA "calculator", "small machine that can add and subtract" DATA "radio", "electric box that receives sound broadcasts" DATA "television", "electric box that receives sound and picture broadcasts" DATA "video cassette player", "electric box that plays films on a television" DATA "audio cassette player", "electric box that plays music tapes" FOR i = 1 TO nInstElec READ InstElecName(i), InstElecDesc(i) NEXT i ' Experimental Apparatus '' Physics Formulas DIM SHARED nFormula nFormula = 37 DIM SHARED FormulaName(nFormula) AS STRING DIM SHARED FormulaDesc(nFormula) AS STRING DATA "speed", "v = d / t" DATA "speed of a wave", "c = /\ x f" DATA "weight", "w = m x g" DATA "acceleration", "a = v / t" DATA "density", "d = m / v" DATA "force", "F = m x a" DATA "extension of a spring", "x = k x F" DATA "work", "W = F x d" DATA "potential energy", "p.e. = m x g x h" DATA "kinetic energy", "k.e. = 1/2 x m x v2" DATA "energy efficiency", "e = Eout / Ein x 100%" DATA "work done = energy used", "E = W" DATA "energy of a nuclear reaction", "E = m x c2" DATA "power", "P = E / t" DATA "law of reflection", "i = r" DATA "Snell's law; index of refraction", "n = sin i / sin r" DATA "current", "I = Q / t" DATA "Ohm's law; Ohmic resistance", "R = V / I" DATA "resistance of a wire", "R = k x l / A" DATA "resistance in series", "R = R1 + R2" DATA "resistance in parallel", "1/R = 1/R1 + 1/R2" DATA "currents in parallel", "I = I1 + I2" DATA "current into a point", "Iin = Iout" DATA "total voltage in a circuit", "V = V1 + V2" DATA "power in an electric circuit", "P = I x V" DATA "energy in an electric circuit", "E = I x V x t" DATA "power in a transformer", "Vp x Ip = Vs x Is" DATA "turns in a transformer", "Vp / Vs = Np / Ns" DATA "area of a square", "a = s2" DATA "area of a rectangle", "a = l x w" DATA "area of a triangle", "a = 1/2 x b x h" DATA "area of a circle", "a = Pi x r2" DATA "volume of a cube", "v = s3" DATA "volume of a cuboid", "v = l x w x h" DATA "volume of a cylinder", "v = Pi x r2 x h" DATA "temperature in degrees Kelvin", "oK = oC + 273" DATA "temperature in degrees Fahrenheit", "oF = 9/5 x oC + 32" FOR i = 1 TO nFormula READ FormulaName(i), FormulaDesc(i) NEXT i '' Units ' Physics Quantities, Units and Symbols DIM SHARED nQuant nQuant = 20 DIM SHARED QuantName(nQuant) AS STRING DIM SHARED QuantSymbol(nQuant) AS STRING DIM SHARED QuantUnits(nQuant) AS STRING DATA "length, focal length, wavelength", "l, h, w, d, f, ...", "km, m (metres), cm, mm" DATA "area", "A", "m2 (square metres), cm2" DATA "volume", "V", "m3 (cubic metres), cm3, l (litres), ml" DATA "time", "t", "h (hours), min (minutes), s (seconds), ms" DATA "speed", "u, v", "km/h, m/s, cm/s" DATA "acceleration", "a", "m/s2" DATA "mass", "m, M", "kg, g (grams)" DATA "weight", "W", "N (Newtons)" DATA "force", "F", "N (Newtons)" DATA "work", "W", "J (Joules)" DATA "energy", "E", "J (Joules)" DATA "power", "P", "W (Watts)" DATA "temperature", "t", "oC (degrees Celsius)" DATA "angle of incidence", "i", "degrees" DATA "angle of reflection, refraction", "r", "degrees" DATA "potential difference, Voltage, EMF", "V, E", "V (Volts), mV" DATA "current", "I", "A (Amperes), mA" DATA "resistance", "R", "Ohms" DATA "charge", "Q", "C (Coulombs)" DATA "frequency", "f, v", "Hz (Hertz), kHz" FOR i = 1 TO nQuant READ QuantName(i), QuantSymbol(i), QuantUnits(i) NEXT i ' Unit Prefixes and Scientific Notation DIM SHARED nPrefix nPrefix = 8 DIM SHARED PrefixName(nPrefix) AS STRING DIM SHARED PrefixValue(nPrefix) AS STRING DATA "mega (M)", "10^6" DATA "kilo (k)", "10^3" DATA "hecto (h)", "10^2" DATA "deca (da)", "10^1" DATA "deci (d)", "10^-1" DATA "centi (c)", "10^-2" DATA "milli (m)", "10^-3" DATA "micro (u)", "10^-6" FOR i = 1 TO nPrefix READ PrefixName(i), PrefixValue(i) NEXT i ' Unit Conversions and Equivalence ' to do this, make random conversion problems '' Constants ' Physics Constants DIM SHARED nConst nConst = 35 DIM SHARED ConstName(nConst) AS STRING DIM SHARED ConstValue(nConst) AS STRING 'speeds DATA "maximum speed of cheetah running", "34 m/s" DATA "maximum speed of man running", "10 m/s" DATA "speed of sound in air", "330 m/s" DATA "speed of sound in water", "1500 m/s" DATA "speed of sound in rock", "5000 m/s" DATA "speed of light in vacuum", "300 000 000 m/s" 'temperatures DATA "normal human body temperature", "37 oC" DATA "melting point of pure water (lower fixed point)", "0 oC" DATA "boiling point of pure water (upper fixed point)", "100 oC" DATA "melting point of iron", "1540 oC" DATA "melting point of mercury", "-39 oC" 'masses DATA "mass of paper clip", "1 g" DATA "mass of 1 litre of water", "1 kg" DATA "mass of average person", "70 kg" DATA "mass of electron", "9.1 x 10^-31 kg" DATA "mass of proton or neutron", "1.67 x 10^-27 kg" 'indices of refraction DATA "index of refraction of water", "1.33" DATA "index of refraction of air", "about 1.0" DATA "index of refraction of diamond", "2.42" DATA "index of refraction of glass", "1.5 to 1.6" 'sound frequencies DATA "sound frequencies heard by man", "20 Hz to 20 kHz" DATA "sound frequencies made by man", "80 Hz to 1 kHz" DATA "sound frequencies heard by a bat", "1 kHz to 100 kHz" 'densities '-solids DATA "density of copper", "8.9 g/cm3" DATA "density of gold", "19.3 g/cm3" DATA "density of wood", "0.6 g/cm3" DATA "density of cork", "0.2 g/cm3" '-liquids DATA "density of pure water", "1.0 g/cm3" DATA "density of mercury", "13.5 g/cm3" DATA "density of paraffin", "0.79 g/cm3" '-gases DATA "density of air", "1.3 kg/m3" DATA "density of hydrogen", "0.09 kg/m3" 'miscellaneous DATA "charge of an electron", "1.6 x 10^-19 C" DATA "acceleration of free fall", "about 9.8 m/s2" DATA "Pi", "3.1415927" FOR i = 1 TO nConst READ ConstName(i), ConstValue(i) NEXT i '' Substances ' Conductors and Insulators ' Magnetic and Non-Magnetic Materials '' Terms ' Laboratory Experiment Terms DIM SHARED nExpTerm nExpTerm = 8 DIM SHARED ExpTermName(nExpTerm) AS STRING DIM SHARED ExpTermDesc(nExpTerm) AS STRING DATA "experiment", "a practical test of a scientific theory" DATA "purpose", "reason for performing an experiment; what is being tested or proven" DATA "hypothesis", "a guess of what will happen in the experiment" DATA "procedure", "a list of steps, methods and techniques taken to perform an experiment" DATA "data", "measurements and other information collected during the experiment" DATA "calculations", "numbers and graphs produced from experimental data" DATA "observations", "what is seen during the experiment" DATA "conclusions", "a summary of the experiment; whether the results proved or disproved the hypothesis, and what was learned" FOR i = 1 TO nExpTerm READ ExpTermName(i), ExpTermDesc(i) NEXT i ' Electromagnetic Spectrum DIM SHARED nSpecTerm nSpecTerm = 11 DIM SHARED SpecTermName(nSpecTerm) AS STRING DIM SHARED SpecTermDesc(nSpecTerm) AS STRING DIM SHARED SpecTermUse(nSpecTerm) AS STRING DATA "gamma rays", "highest energy radiation; emitted by the sun, nuclear bombs, nuclear reactors and radioactive sources; causes cancer and genetic mutations (changes), dangerous", "sterilises food and surgical instruments, kills germs and cancer cells" DATA "x rays", "low energy gamma rays, ionise gases, produced by high voltage", "taking pictures inside the body, absorbed by bones, go through flesh" DATA "ultraviolet", "causes sunburn and skin cancer, produced by the sun, stopped by the ozone layer", "getting sun tan; helps with production of vitamin D" DATA "visible light", "different wavelengths are seen by the human eye as colours", "cameras, eyes, photosynthesis" DATA "black", "absence of light", "good radiators" DATA "white", "mixture of all visible colours of light, split by a prism to produce the visible spectrum", "good reflectors" DATA "violet", "highest energy colour, bent most by a prism", "flowers" DATA "red", "lowest energy colour, bent least by a prism", "warning lights" DATA "infrared", "heat; produced in fires, heaters, hot objects; easily absorbed", "cooking, heating, photographs in the dark" DATA "microwaves", "high energy radio waves", "cooking food quickly, sending telephone messages through the air" DATA "radio waves", "lowest energy radiation", "radio and television broadcasts; long-distance and satellite communications" FOR i = 1 TO nSpecTerm READ SpecTermName(i), SpecTermDesc(i), SpecTermUse(i) NEXT i ' Energy Sources DIM SHARED nesource nesource = 13 DIM SHARED ESourceName(nesource) AS STRING DIM SHARED ESourceFormed(nesource) AS STRING DIM SHARED ESourceCollected(nesource) AS STRING DIM SHARED ESourceUsed(nesource) AS STRING DIM SHARED ESourcePollution(nesource) AS STRING DATA "crude oil", "black liquid fossil fuel formed from high pressure underground", "drawn from underground wells", "burned to produce heat", "hydrocarbons, sulphur dioxide, carbon dioxide, carbon monoxide" DATA "petrol", "clear liquid fossil fuel found in crude oil", "fractional distillation of crude oil", "burned in car engines", "hydrocarbons, carbon dioxide, carbon monoxide, sulphur dioxide, nitrogen oxides, lead" DATA "coal", "hard, black fossil fuel formed from high pressure underground", "mined from the ground", "burned to produce heat and generate electricity", "ash, hydrocarbons, sulphur dioxide, carbon dioxide, carbon monoxide" DATA "natural gas", "light weight hydrocarbons trapped in the earth", "drilled from underground", "burned in special stoves for cooking and heating", "carbon dioxide, carbon monoxide" DATA "nuclear", "naturally occurring radioactive substances like uranium", "mined from the ground and refined for a higher concentration", "fission produces heat to generate electricity", "radioactive waste" DATA "solar", "light and heat energy from fusion in the sun", "photovoltaic cells or panels containing water", "heat or light is converted to electricity", "no pollution" DATA "hydroelectric", "evaporation of water and rain on high areas", "falling water turns a wheel or turbine", "turbine converts potential energy to electricity", "dams can cause flooding" DATA "wind", "changing temperatures cause air to move", "turns mills", "generates electricity, pumps water or grinds grain", "no pollution" DATA "waves and tides", "water moves because of gravity and wind", "devices are moved when the water moves back and forth", "motion generates electricity", "no pollution" DATA "wood", "organic substance found in trees", "cutting down of trees (deforestation)", "burning in stoves in houses for heating and cooking", "ash, carbon dioxide, carbon monoxide" DATA "biomass", "solid rotting organic substances", "collection of plant and animal waste", "burned to produce heat", "ash, carbon dioxide, carbon monoxide" DATA "biogas", "light weight hydrocarbons from rotting organic substances", "trapped in underground containers", "burned in special stoves for cooking", "carbon dioxide, carbon monoxide, biomass" DATA "geothermal", "heat in the earth due to gravity", "water is pumped under the ground", "heat from the ground generates electricity", "holes in the ground" FOR i = 1 TO nesource READ ESourceName(i), ESourceFormed(i), ESourceCollected(i), ESourceUsed(i), ESourcePollution(i) NEXT i ' Energy Forms DIM SHARED neform neform = 10 DIM SHARED EFormName(neform) AS STRING DIM SHARED EFormDesc(neform) AS STRING DATA "potential", "stored energy of position" DATA "kinetic", "released energy of motion" DATA "gravitational", "attraction between any two objects with mass" DATA "magnetic", "attraction or repulsion between two metal objects" DATA "electric", "attraction or repulsion between two charges" DATA "chemical", "attraction to form bonds in molecules" DATA "nuclear", "attraction between particles inside an atom's centre" DATA "wave", "transverse or longitudinal oscillation of particles in a medium" DATA "radiant", "energy in an electromagnetic wave" DATA "sound", "longitudinal waves in a medium that can be detected by the human ear" FOR i = 1 TO neform READ EFormName(i), EFormDesc(i) NEXT i ' Science Paper Terms ' equipment ' techniques ' Miscellaneous Terms DIM SHARED nterm nterm = 41 DIM SHARED TermName(nterm) AS STRING DIM SHARED TermDef(nterm) AS STRING 'These should be separated by syllabus topic 'General DATA "physics", "study of the interaction of matter and energy" 'General Physics DATA "length", "distance from one end of an object to the other end" DATA "time", "duration of an event with a beginning and end" DATA "speed", "rate of change of distance over time" DATA "velocity", "vector with speed as the magnitude" DATA "acceleration", "rate of change of speed over time" DATA "mass", "a measure of the amount of matter of an object" DATA "weight", "a measure of the pull of the force of gravity on an object" DATA "volume", "the space that an object occupies" DATA "density", "mass per unit volume of an object or substance" DATA "force", "a push (attraction) or pull (repulsion)" DATA "centre of mass", "the point at which the entire object seems to act, and on which an object can balance" DATA "moment", "turning effect; force perpendicular to pivot times distance from pivot" DATA "energy", "ability to do work" DATA "work", "applying a force to move some distance" DATA "power", "rate of doing work over time" 'Thermal Physics DATA "temperature", "a measure of the thermal (heat) energy of a substance" DATA "conduction", "transfer of heat by moving electrons" DATA "convection", "transfer of heat by moving molecules or larger particles" DATA "radiation", "transfer of heat by electromagnetic waves" 'Physics of Waves DATA "wave", "transfer of energy by oscillation of particles" DATA "light", "visible electromagnetic radiation" DATA "reflection", "wave bounces off a boundary between two media" DATA "refraction", "wave moves into a different medium and changes speed" DATA "lens", "curved piece of glass or material which refracts light" DATA "electromagnetic spectrum", "the range of all possible wavelengths of radiation" 'Electricity and Magnetism DATA "magnet", "piece of metal which attracts or repels some other pieces of metal" DATA "electrostatics", "study of non-moving charges" 'Atomic Physics DATA "radioactive", "substance which randomly emits particles and energy" DATA "alpha particle", "nucleus of a helium atom emitted by a radioactive substance" DATA "beta particle", "electron emitted by a radioactive substance" DATA "gamma ray", "electromagnetic radiation emitted by a radioactive substance" 'Geometry DATA "angle", "degrees of arc in a circle" DATA "curve", "line that is not straight" DATA "circle", "round curve whose points are an equal distance from a centre point" DATA "radius", "distance from the centre of a circle to the outside edge" DATA "diameter", "distance from one edge of a circle to the other edge through the centre" DATA "square", "four-sided shape with four equal sides and four right angles" DATA "parallelogram", "four-sided shape with two sets of two equal, parallel lines" DATA "rectangle", "four-sided shape with two sets of two equal sides and four right angles" DATA "diagonal", "line from one corner through the centre to the opposite corner of a four-sided shape" FOR i = 1 TO nterm READ TermName(i), TermDef(i) NEXT i 'Calculations DIM SHARED nEquations nEquations = 60 DIM SHARED eqType(nEquations), eqVars(nEquations), eqLevel(nEquations) DIM SHARED eqConst(nEquations), eqConstName(nEquations) AS STRING, eqConstUnit(nEquations) AS STRING DIM SHARED eqVar(nEquations, 4) AS STRING, eqUnit(nEquations, 4) AS STRING 'General DATA 1, 3, 1, 1, "distance", "m", "speed", "m/s", "time", "s" DATA 1, 3, 2, 1, "change in speed", "m/s", "acceleration", "m/s2", "change in time", "s" DATA 3, 3, 3, 0.5, "", "", "distance", "m", "time", "s", "acceleration", "m/s2" DATA 1, 3, 1, 1, "mass", "g", "density", "g/cm3", "volume", "cm3" DATA 1, 3, 2, 1, "force", "N", "mass", "kg", "acceleration", "m/s2" DATA 1, 2, 1, 9.8, "acceleration of gravity", "m/s2", "weight", "N", "mass", "kg" DATA 1, 3, 3, 1, "force", "N", "pressure", "N/m2", "area", "m2" DATA 1, 3, 3, 9.8, "acceleration of gravity", "m/s2", "pressure", "N/m2", "density", "kg/m3", "height", "m" DATA 1, 3, 2, 1, "extension", "cm", "spring constant", "cm/N", "load", "N" DATA 1, 3, 3, 1, "momentum", "kg x m/s", "mass", "kg", "speed", "m/s" DATA 1, 3, 2, 1, "moment", "N x m", "force", "N", "perpendicular distance", "m" DATA 2, 4, 3, 1, "pressure", "N/m2", "volume", "m3", "constant", "Nxm/oK", "temperature", "oK" 'Energy DATA 1, 2, 1, 1, "energy used", "J", "work done", "J" DATA 1, 3, 1, 1, "work", "J", "force", "N", "distance", "m" DATA 1, 3, 1, 1, "energy", "J", "power", "W", "time", "s" DATA 1, 4, 3, 1, "heat energy", "J", "mass", "kg", "specific heat capacity", "J/kg oC", "temperature change", "oC" DATA 3, 3, 2, 0.5, "", "", "kinetic energy", "J", "velocity", "m/s", "mass", "kg" DATA 2, 3, 3, 100, "percent", "%", "percent energy efficiency", "%", "energy input", "J", "energy output", "J" DATA 1, 2, 2, 9e16, "speed of light squared", "m2/s2", "energy of nuclear reaction", "J", "mass", "kg" DATA 1, 3, 2, 9.8, "acceleration of gravity", "m/s2", "potential energy", "J", "mass", "kg", "height", "m" 'Waves DATA 1, 2, 1, 1, "angle of incidence", "degrees", "angle of reflection", "degrees" DATA 2, 2, 2, 1, "period", "s", "frequency", "Hz" DATA 1, 3, 2, 1, "speed of wave", "m/s", "frequency", "Hz", "wavelength", "m" 'Electricity and Magnetism DATA 1, 3, 1, 1, "voltage", "V", "resistance", "Ohms", "current", "A" DATA 1, 2, 1, 1, "total current into point", "A", "total current out of point", "A" DATA 4, 3, 1, 1, "total resistance in series", "Ohms", "resistor1", "Ohms", "resistor2", "Ohms" DATA 5, 3, 2, 1, "total resistance in parallel", "Ohms", "resistor1", "Ohms", "resistor2", "Ohms" DATA 4, 3, 2, 1, "total current in parallel", "A", "current1", "A", "current2", "A" DATA 4, 3, 2, 1, "e.m.f. of source", "V", "p.d. of component1", "V", "p.d. of component2", "V" DATA 2, 4, 1, 1, "voltage in the primary coil", "V", "current in the primary coil", "A", "voltage in the secondary coil", "V", "current in the secondary coil", "A" DATA 2, 4, 2, 1, "voltage in the primary coil", "V", "number of turns in the secondary coil", "turns", "voltage in the secondary coil", "V", "number of turns in the primary coil", "turns" DATA 2, 4, 2, 1, "resistance", "Ohms", "cross-sectional area", "mm2", "length", "mm", "constant", "Ohms x mm" DATA 1, 3, 2, 1, "charge", "C", "current", "A", "time", "s" DATA 1, 3, 3, 1, "charge", "C", "capacitance", "F", "voltage", "V" DATA 1, 4, 2, 1, "energy", "J", "current", "A", "voltage", "V", "time", "s" DATA 1, 3, 2, 1, "power", "W", "current", "A", "voltage", "V" 'Geometry DATA 3, 2, 1, 1, "area of square", "cm2", "length of side", "cm" DATA 1, 3, 1, 1, "area of rectangle", "cm2", "length", "cm", "width", "cm" DATA 1, 3, 1, 0.5, "", "", "area of triangle", "cm2", "base", "cm", "height", "cm" DATA 3, 2, 2, 3.14, "Pi", "", "area of circle", "cm2", "radius", "cm" DATA 1, 4, 1, 1, "volume of cuboid", "cm3", "length", "cm", "width", "cm", "height", "cm" DATA 3, 3, 2, 3.14, "Pi", "", "volume of cylinder", "cm3", "radius", "cm", "height", "cm" 'Unit Conversions DATA 1, 2, 1, 1000, "conversion factor", "m/km", "length", "m", "length", "km" DATA 1, 2, 1, 100, "conversion factor", "cm/m", "length", "cm", "length", "m" DATA 1, 2, 1, 1000, "conversion factor", "mm/m", "length", "mm", "length", "m" DATA 1, 2, 2, 1e4, "conversion factor", "cm2/m2", "area", "cm2", "area", "m2" DATA 1, 2, 2, 1e6, "conversion factor", "cm3/m3", "volume", "cm3", "volume", "m3" DATA 1, 2, 1, 1000, "conversion factor", "ml/l", "volume", "ml", "volume", "l" DATA 1, 2, 2, 1000, "conversion factor", "(kg/m3)/(g/cm3)", "volume", "kg/m3", "volume", "g/cm3" DATA 1, 2, 1, 60, "conversion factor", "s/min", "time", "s", "time", "min" DATA 1, 2, 1, 60, "conversion factor", "min/h", "time", "min", "time", "h" DATA 1, 2, 1, 3600, "conversion factor", "s/h", "time", "s", "time", "h" DATA 1, 2, 1, 100, "conversion factor", "cm/m", "speed", "cm/s", "speed", "m/s" DATA 1, 2, 2, 3.6, "conversion factor", "(km/h)/(m/s)", "speed", "km/h", "speed", "m/s" DATA 1, 2, 2, 1000, "conversion factor", "kg/tonne", "mass", "kg", "mass", "tonnes" DATA 1, 2, 1, 1000, "conversion factor", "g/kg", "mass", "g", "mass", "kg" DATA 1, 2, 1, 1000, "conversion factor", "mg/g", "mass", "mg", "mass", "g" DATA 1, 2, 1, 1000, "conversion factor", "mV/V", "potential difference", "mV", "potential difference", "V" DATA 1, 2, 1, 1000, "conversion factor", "mA/A", "current", "mA", "current", "A" DATA 6, 2, 3,273.15,"conversion factor", "", "temperature", "oK", "temperature", "oC" FOR i = 1 TO nEquations READ eqType(i), eqVars(i), eqLevel(i), eqConst(i) IF eqConst(i) <> 1 THEN READ eqConstName(i), eqConstUnit(i) FOR j = 1 TO eqVars(i) READ eqVar(i, j), eqUnit(i, j) NEXT j 'CALL PrintEquation(i) NEXT i ' Main Loop DIM SHARED playsound playsound = 1 PLAY "l16" RANDOMIZE TIMER DIM SHARED starttime starttime = TIMER CALL mainhelp DO CALL mainmenu LOOP FUNCTION CalcEquation (eq, solveFor, a, b, c, d, constant) REM equation: the type of equation to be solved REM solveFor: the variable to solve REM a, b, c, d: the equation variables REM constant: the equation constant REM return value: the result of an equation errcode = 0 IF eqVars(eq) < 2 THEN b = 1 IF eqVars(eq) < 3 THEN c = 1 IF eqVars(eq) < 4 THEN d = 1 SELECT CASE eqType(eq) CASE 1 ' a = constant * b * c * d SELECT CASE solveFor CASE 1: CalcEquation = constant * b * c * d CASE 2: CalcEquation = a / (constant * c * d) CASE 3: CalcEquation = a / (constant * b * d) CASE 4: CalcEquation = a / (constant * b * c) CASE ELSE: errcode = 1 END SELECT CASE 2 ' a * b = constant * c * d SELECT CASE solveFor CASE 1: CalcEquation = constant * c * d / b CASE 2: CalcEquation = constant * c * d / a CASE 3: CalcEquation = a * b / (constant * d) CASE 4: CalcEquation = a * b / (constant * c) CASE ELSE: errcode = 1 END SELECT CASE 3 ' a = constant * b ^ 2 * c * d SELECT CASE solveFor CASE 1: CalcEquation = constant * b ^ 2 * c * d CASE 2: CalcEquation = SQR(a / (constant * c * d)) CASE 3: CalcEquation = a / (constant * b ^ 2 * d) CASE 4: CalcEquation = a / (constant * b ^ 2 * c) CASE ELSE: errcode = 1 END SELECT CASE 4 ' a = b + c SELECT CASE solveFor CASE 1: CalcEquation = b + c CASE 2: CalcEquation = a - c CASE 3: CalcEquation = a - b CASE ELSE: errcode = 1 END SELECT CASE 5 '1 / a = 1 / b + 1 / c SELECT CASE solveFor CASE 1: CalcEquation = 1 / (1 / b + 1 / c) CASE 2: CalcEquation = 1 / (1 / a - 1 / c) CASE 3: CalcEquation = 1 / (1 / a - 1 / b) CASE ELSE: errcode = 1 END SELECT CASE 6 ' a = b + constant SELECT CASE solveFor CASE 1: CalcEquation = b + constant CASE 2: CalcEquation = a - constant CASE ELSE: errcode = 1 END SELECT CASE ELSE: errcode = 1 END SELECT IF errcode = 1 THEN PRINT "Error in CalcEquation: "; eq; solveFor; a; b; c; d; constant: CalcEquation = 0 END FUNCTION SUB categorymenu CLS PRINT progname; " - Question Category" PRINT PRINT 0, "Random", IF category = 0 THEN PRINT "<----" ELSE PRINT FOR i = 1 TO ncat PRINT i, CatName(i), IF i = category THEN PRINT "<----" ELSE PRINT NEXT i PRINT INPUT "Enter the number of a category"; category DO WHILE category < 0 OR category > ncat PRINT "Please enter a number from 0 to"; ncat INPUT category LOOP END SUB SUB definition (array1() AS STRING, array2() AS STRING, term AS STRING, nterms) IF RND > .5 THEN PRINT "What is the description of this "; term; "?" CALL match(array1(), array2(), nterms, nchoices) ELSE PRINT "What is the name of the "; term; " with this description?" CALL match(array2(), array1(), nterms, nchoices) END IF END SUB SUB equation DIM value(4) DO eq = irand(nEquations) LOOP WHILE level <> 0 AND level <> eqLevel(eq) var = irand(eqVars(eq)) PRINT "Difficulty level: "; LevelName(eqLevel(eq)) PRINT CALL PrintEquation(eq) PRINT z = irand(3) FOR i = 1 TO eqVars(eq) IF i <> var THEN SELECT CASE z CASE 1: value(i) = irand(10) * 10 ^ (irand(2) - 2) CASE 2: value(i) = 10 ^ (irand(5) - 3) CASE 3: value(i) = 2 ^ (irand(5) - 3) END SELECT PRINT "The "; eqVar(eq, i); " is"; value(i); eqUnit(eq, i); "." END IF NEXT i 'IF eqConst(eq) <> 1 THEN PRINT "The "; eqConstName(eq); " is "; eqConst(eq); eqConstUnit(eq); "." PRINT PRINT "What is the "; eqVar(eq, var); " in "; eqUnit(eq, var); INPUT choice ans = CalcEquation(eq, var, value(1), value(2), value(3), value(4), eqConst(eq)) CALL mark(choice, ans) END SUB FUNCTION irand (i) irand = INT(RND * i) + 1 END FUNCTION SUB levelmenu CLS PRINT progname; " - Difficulty Level" PRINT PRINT 0, "Random", IF level = 0 THEN PRINT "<----" ELSE PRINT FOR i = 1 TO nlevels PRINT i, LevelName(i), IF i = level THEN PRINT "<----" ELSE PRINT NEXT i PRINT INPUT "Enter the level number"; level DO WHILE level < 0 OR level > nlevels PRINT "Please enter a number from 0 to"; nlevels INPUT nlevels LOOP END SUB SUB mainhelp CLS PRINT progname PRINT PRINT "This program tests your knowledge of physics." PRINT "It is loosely based on the Cambridge IGCSE Physical Science syllabus." PRINT CALL pause END SUB SUB mainmenu CLS PRINT progname; " - Main Menu" PRINT IF tries = 0 THEN score = 0 ELSE score = INT(correct / tries * 100) PRINT "Correct Answers: "; correct PRINT "Questions Tried: "; tries PRINT "Percent Score: "; score; "%" IF correct > 0 THEN PRINT "Average Time per Correct Answer:"; INT((TIMER - starttime) / correct); "seconds" PRINT PRINT "Question Category: "; IF category = 0 THEN PRINT " 0 (Random)" ELSE PRINT category; "("; CatName(category); ")" END IF IF category >= 15 THEN PRINT "Difficulty Level: "; IF level = 0 THEN PRINT " 0 (Random)" ELSE PRINT level; "("; LevelName(level); ")" END IF END IF PRINT "Multiple Choice Options: "; nchoices PRINT "Sound: "; IF playsound > 0 THEN PRINT "On" ELSE PRINT "Off" PRINT PRINT "Press Enter to try the next question." PRINT "Press R to reset the score to zero." PRINT "Press Q to change the question category." IF category >= 15 THEN PRINT "Press L to change the difficulty level." END IF PRINT "Press M to change the number of multiple choice options." PRINT "Press S to turn sounds on or off." PRINT "Press I to display information about this program." PRINT "Press Esc to exit this program." DO a$ = INKEY$ LOOP WHILE a$ = "" SELECT CASE a$ CASE CHR$(13) 'enter CALL question CASE "r" correct = 0 tries = 0 starttime = TIMER CASE "q" CALL categorymenu CASE "l" CALL levelmenu CASE "m" CLS DO PRINT "Enter the number of choices for multiple choice questions (2 to 9)" INPUT nchoices IF nchoices < 2 OR nchoices > 9 THEN PRINT "You must enter a number from 2 to 9." LOOP WHILE nchoices < 2 OR nchoices > 9 CASE "s" playsound = -playsound CASE "i" CALL mainhelp CASE CHR$(27) 'esc CLS 'PRINT "You have exited the program." 'PRINT "To return to Windows, press Alt, press F, and press X." 'END SYSTEM 'CHAIN "c:\users\vogl\basic\exit.bas" CASE ELSE PRINT PRINT "Sorry, you have made an invalid choice." CALL pause END SELECT END SUB SUB mark (choice, ans) IF choice = ans THEN IF playsound > 0 THEN PLAY "CF" PRINT "Correct!" correct = correct + 1 ELSE IF playsound > 0 THEN PLAY "FDD" PRINT "Incorrect. The correct answer is:" PRINT ans END IF tries = tries + 1 PRINT END SUB SUB match (qarray() AS STRING, aarray() AS STRING, narray, nans) DIM temp(nans) AS STRING na = nans IF narray < na THEN na = narray ' to avoid infinite loops DO ques = irand(narray) LOOP WHILE qarray(ques) = "" OR aarray(ques) = "" ans = irand(na) PRINT qarray(ques) PRINT FOR i = 1 TO na IF ans = i THEN j = ques ELSE DO j = irand(narray) flag = 0 FOR k = 1 TO i - 1 IF temp(k) = aarray(j) THEN flag = 1 NEXT k LOOP WHILE j = ques OR qarray(j) = "" OR aarray(j) = "" OR flag = 1 END IF temp(i) = aarray(j) PRINT i; temp(i) NEXT i CALL qmark(ans, na) END SUB SUB number (qarray() AS STRING, aarray(), nques) n = irand(nques) PRINT qarray(n) INPUT choice CALL mark(choice, aarray(n)) END SUB SUB pause ' PRINT "Press any key to continue." PRINT "Press Enter to continue." DO a$ = INKEY$ ' LOOP WHILE a$ = "" LOOP WHILE a$ <> CHR$(13) 'Enter END SUB SUB PrintEquation (eq) DIM var$(4) times$ = " x " plus$ = " + " equals$ = " = " FOR i = 1 TO eqVars(eq) var$(i) = eqVar(eq, i) + " (" + eqUnit(eq, i) + ")" NEXT i const$ = eqConstName(eq) + " (" + STR$(eqConst(eq)) + " " + eqConstUnit(eq) + ")" SELECT CASE eqType(eq) CASE 1 PRINT var$(1); equals$; IF eqConst(eq) <> 1 THEN PRINT const$; times$; PRINT var$(2); IF eqVars(eq) >= 3 THEN PRINT times$; var$(3); IF eqVars(eq) >= 4 THEN PRINT times$; var$(4); PRINT CASE 2 PRINT var$(1); times$; PRINT var$(2); equals$; IF eqConst(eq) <> 1 OR (eqConst(eq) = 1 AND eqVars(eq) < 3) THEN PRINT const$; IF eqConst(eq) <> 1 AND eqVars(eq) >= 3 THEN PRINT times$; IF eqVars(eq) >= 3 THEN PRINT var$(3); IF eqVars(eq) >= 4 THEN PRINT times$; var$(4); PRINT CASE 3 PRINT var$(1); equals$; IF eqConst(eq) <> 1 THEN PRINT const$; times$; PRINT var$(2); " squared"; IF eqVars(eq) >= 3 THEN PRINT times$; var$(3); IF eqVars(eq) >= 4 THEN PRINT times$; var$(4); PRINT CASE 4 PRINT var$(1); equals$; PRINT var$(2); plus$; PRINT var$(3); PRINT CASE 5 PRINT " 1 / "; var$(1); equals$; PRINT " 1 / "; var$(2); plus$; PRINT " 1 / "; var$(3); PRINT CASE 6 PRINT var$(1); equals$; PRINT var$(2); plus$; PRINT const$; PRINT CASE ELSE: PRINT "Error in PrintEquation"; eq END SELECT END SUB SUB qmark (ans, nans) PRINT PRINT "Press a number from 1 to"; nans; "." DO a$ = INKEY$ IF a$ <> "" THEN choice = ASC(a$) - ASC("0") LOOP WHILE a$ = "" OR choice < 1 OR choice > nans PRINT choice PRINT CALL mark(choice, ans) END SUB SUB question CLS PRINT progname; PRINT cat = category IF category = 0 THEN cat = irand(ncat) PRINT "Question Category: "; cat; "("; CatName(cat); ")" PRINT SELECT CASE cat CASE 1 CALL definition(InstMeasName(), InstMeasDesc(), "measuring instrument", nInstMeas) CASE 2 CALL definition(InstCircName(), InstCircDesc(), "circuit component", nInstCirc) CASE 3 CALL definition(InstOptName(), InstOptDesc(), "optical instrument", nInstOpt) CASE 4 CALL definition(InstMusicName(), InstMusicDesc(), "musical instrument", nInstMusic) CASE 5 CALL definition(InstElecName(), InstElecDesc(), "electrical appliance", nInstElec) CASE 6 CALL definition(FormulaName(), FormulaDesc(), "formula", nFormula) CASE 7 SELECT CASE INT(RND * 4) CASE 0 PRINT "What is the symbol for this quantity?" CALL match(QuantName(), QuantSymbol(), nQuant, nchoices) CASE 1 PRINT "What is the quantity for this symbol?" CALL match(QuantSymbol(), QuantName(), nQuant, nchoices) CASE 2 PRINT "What are the units for this quantity?" CALL match(QuantName(), QuantUnits(), nQuant, nchoices) CASE 3 PRINT "What is the quantity for these units?" CALL match(QuantUnits(), QuantName(), nQuant, nchoices) END SELECT CASE 8 CALL definition(PrefixName(), PrefixValue(), "prefix", nPrefix) CASE 9 CALL definition(ConstName(), ConstValue(), "constant", nConst) CASE 10 CALL definition(ExpTermName(), ExpTermDesc(), "experiment term", nExpTerm) CASE 11 SELECT CASE INT(RND * 2) CASE 0 CALL definition(SpecTermName(), SpecTermDesc(), "electromagnetic radiation", nSpecTerm) CASE 1 CALL definition(SpecTermName(), SpecTermUse(), "electromagnetic radiation", nSpecTerm) END SELECT CASE 12 SELECT CASE INT(RND * 8) CASE 0 PRINT "How is this energy source formed?" CALL match(ESourceName(), ESourceFormed(), nesource, nchoices) CASE 1 PRINT "Which of these energy sources is formed this way?" CALL match(ESourceFormed(), ESourceName(), nesource, nchoices) CASE 2 PRINT "How is this energy source collected?" CALL match(ESourceName(), ESourceCollected(), nesource, nchoices) CASE 3 PRINT "Which of these energy sources is collected this way?" CALL match(ESourceCollected(), ESourceName(), nesource, nchoices) CASE 4 PRINT "How is this energy source used?" CALL match(ESourceName(), ESourceUsed(), nesource, nchoices) CASE 5 PRINT "Which of these energy sources is used this way?" CALL match(ESourceUsed(), ESourceName(), nesource, nchoices) CASE 6 PRINT "What types of pollution does this energy source make?" CALL match(ESourceName(), ESourcePollution(), nesource, nchoices) CASE 7 PRINT "Which of these energy sources produces these types of pollution?" CALL match(ESourcePollution(), ESourceName(), nesource, nchoices) END SELECT CASE 13 CALL definition(EFormName(), EFormDesc(), "energy form", neform) CASE 14 CALL definition(TermName(), TermDef(), "term", nterm) CASE 15 CALL equation CASE ELSE PRINT "This question category does not exist yet." END SELECT CALL pause END SUB