online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
! this is a comment ! code 999 - invalid input !CALL random_number(rNum) !rNum = NINT(rNum) !PRINT *, rNum ! INTEREST CALCULATOR | MONTHLY/YEARLY DISPLAY EACH INTERVAL !========================================================== program hello IMPLICIT none INTEGER :: inputOperation, selectedProgram, selectedTempConvert, selectedGamblingGame, numCorrect CHARACTER :: operation REAL :: number1, number2 INTEGER :: enteredF, enteredC, finalF, finalC, n, rngResult REAL :: x1, x2, y1, y2, a, b, c, d, e, h, r, s, mpFoundX, mpFoundY, foundArea, selectedAreaFind = 0 INTEGER :: currentBet, rouletteBet, i REAL :: rNum, finalnum INTEGER :: balance = 500 CHARACTER :: blackjackHorS INTEGER :: temp1, temp2c, temp2k, temp2f, temp2r, temp2 CHARACTER :: temp1unit, temp2unit INTEGER :: f, f1, f2, selected6Program, extraVar, g, remainingGuesses, enteredGuess INTEGER :: strModifier, dexModifier, conModifier, intModifier, chaModifier, wisModifier INTEGER :: uSeconds, unitM, unitH, unitD, unitW, unitMo, unitY, unitDe, unitC INTEGER :: debugMode INTEGER :: selectedDiceRoll, rpsBet, baseValue, selected5subProgram INTEGER :: extraInt, selected1Program, selected3program, selected3subprogram, baseUnit, desiredUnit, desiredTime REAL :: topFraction, bottomFraction REAL :: decimalFinal INTEGER :: angleA, angleB, angleC CHARACTER :: topL = '1' CHARACTER :: topM = '2' CHARACTER :: topR = '3' CHARACTER :: midL = '4' CHARACTER :: midM = '5' CHARACTER :: midR = '6' CHARACTER :: botL = '7' CHARACTER :: botM = '8' CHARACTER :: botR = '9' CHARACTER :: playerToken INTEGER :: ticTacToeGame = 1 INTEGER :: cc1, cc2, cc3, cc4, cc5, cc6, cc7, cc8 CHARACTER(len=500):: currentSave, save1, save2, save3, save4, save5 = 'EMPTY' INTEGER :: selectedAline = 0 CHARACTER :: angleAmeasure, angleBmeasure, angleCmeasure INTEGER :: cardNum, selectedScienceProgram CHARACTER(len=8):: cardSuit, unknownVar CHARACTER(len=8):: suitGraphic1, suitGraphic2, suitGraphic3 CHARACTER(len=1):: suitIcon CHARACTER(len=8):: intrType, intrIntv INTEGER :: num1, num2, num3, num4, solution, enteredSol, selectedDisplay INTEGER :: sort1, sort1final, sort2, sort2final, sort3, sort3final, sort4, sort4final, sort5, sort5final CHARACTER(len=30):: aLine0, aLine1, aLine2, aLine3, aLine4, aLine5 = ' ' CHARACTER(len=500), allocatable :: saves(:) INTEGER :: sideA, sideB, sideC REAL :: p1, p2, v1, v2, t1, t2 REAL :: P, V, gasN, T, gasFinalNum REAL :: intr1, intr3, intrRate = 0 INTEGER :: intr2, intr4 x1 = 0.0 x2 = 0.0 y1 = 0.0 x2 = 0.0 mpFoundY = 0.0 mpFoundX = 0.0 allocate(saves(10)) DO n = 1, 75 ! start at 1, do loop 75 times PRINT *, ' ' END DO PRINT *, '-------------------------Welcome to sOS-------------------------' IF(selectedProgram == 666) THEN debugMode = 1 END IF DO IF(debugMode == 1)THEN PRINT *, 'debug mode on' END IF PRINT *, 'welcome! what program would you like to use?' PRINT *, '1 - sCalculator' PRINT *, '2 - sUnitConverter' PRINT *, '3 - sOrtingAlgorithm (not working)' PRINT *, '4 - sCardDeck' PRINT *, '5 - sCasino' PRINT *, '6 - sOmething Else' PRINT *, '----------------------------------------------------------------' READ (*,*) selectedProgram IF(selectedProgram == 666) THEN debugMode = 1 END IF IF(selectedProgram == 1) THEN PRINT *, '1 - simple calculations ( + - * / )' PRINT *, '2 - fraction to decimal' PRINT *, '3 - midpoint finder' PRINT *, '4 - area calculator' PRINT *, '5 - triangle classification' PRINT *, '6 - scientific' PRINT *, '7 - collatz conjecture' PRINT *, '8 - interest calculator' READ (*,*) selected1Program IF(selected1Program == 1) THEN PRINT *, 'enter number1' READ (*,*) number1 PRINT *, 'enter number2' READ (*,*) number2 PRINT *, 'what operation would you like to execute?' PRINT *, '1 - addition' PRINT *, '2 - subtraction' PRINT *, '3 - multipulcation' PRINT *, '4 - division' READ (*,*) inputOperation IF (inputOperation == 1) THEN operation = '+ ' finalnum = number1 + number2 ELSE IF (inputOperation == 2) THEN operation = '- ' finalnum = number1 - number2 ELSE IF (inputOperation == 3) THEN operation = '* ' finalnum = number1 * number2 ELSE IF(inputOperation == 4) THEN operation = '/ ' finalnum = number1 / number2 !ELSE !PRINT *, 'error :3' !call EXIT(999) END IF ! ending program 1 WRITE(*, '(A,F6.2,A,A,A,F6.2,A,F10.2)') 'the value of ', number1, ' ', operation,' ', number2, ' is: ', finalnum ELSE IF(selected1Program == 2) THEN !fraction to decimal | 3=y/x=4 | divide 100 by x, add x y amount of times PRINT *, 'enter the fraction you want to convert to a decimal' PRINT *, 'top number:' READ (*,*) topFraction PRINT *, 'bottom number:' READ (*,*) bottomFraction decimalFinal = topFraction / bottomFraction WRITE(*,'(A,F6.2,A,F6.2,A,F6.2)') 'your fraction, ', topFraction, '/', bottomFraction, ' as a decimal is ', decimalFinal ELSE IF(selected1Program == 3) THEN CALL midpointFind(x1, x2, y1, y2, mpFoundX, mpFoundY) WRITE(*, '(A,F6.2,A,F6.2,A)') "the midpoint is: (", mpFoundX, ',', mpFoundY, ')' ELSE IF(selected1Program == 4) THEN PRINT *, 'what do you want to find the area of?' PRINT *, '1 - square' PRINT *, '2 - rectangle' PRINT *, '3 - circle' PRINT *, '4 - triangle' PRINT *, '5 - parallelogram' PRINT *, '6 - trapezoid' PRINT *, '7 - ellipse' READ (*,*) selectedAreaFind CALL findArea(selectedAreaFind) ELSE IF(selected1Program == 5) THEN !selected1program 5 !acute = 3 angles less than 90 !equianangular = all angles equal !obtuse = one angle over 90 !right = one angle 90, others 45 WRITE(*,'(A)') 'are the measures of angles or sides known?' WRITE(*,'(A)') '1 - angles' WRITE(*,'(A)') '2 - sides' READ(*,*) selected5subProgram IF(selected5subProgram == 1)THEN WRITE(*,'(A)') 'enter the first angle measure, `a`' READ(*,*) angleA WRITE(*,'(A)') 'enter the second angle measure, `b`' READ(*,*) angleB WRITE(*,'(A)') 'enter the third angle measure, `c`' READ(*,*) angleC IF(angleA > 90)THEN angleAmeasure = 'o' ELSE IF(angleA == 90)THEN angleAmeasure = 'r' ELSE IF(angleA < 90)THEN angleAmeasure = 'a' END IF IF(angleB > 90)THEN angleBmeasure = 'o' ELSE IF(angleB == 90)THEN angleBmeasure = 'r' ELSE IF(angleB < 90)THEN angleBmeasure = 'a' END IF IF(angleC > 90)THEN angleCmeasure = 'o' ELSE IF(angleC == 90)THEN angleCmeasure = 'r' ELSE IF(angleC < 90)THEN angleCmeasure = 'a' END IF IF(angleA + angleB + angleC /= 180)THEN PRINT *, 'nah fam that aint no triangle' END IF IF(angleA + angleB + angleC == 180)THEN PRINT *, 'yup, thats a triangle' IF(angleA == angleB .AND. angleB == angleC)THEN PRINT *, 'equilateral triangle' ELSE IF(angleAmeasure == 'r' .OR. angleBmeasure == 'r' .OR. angleCmeasure == 'r')THEN PRINT *, 'right triangle' ELSE IF(angleAmeasure == 'o' .OR. angleBmeasure == 'o' .OR. angleCmeasure == 'o')THEN PRINT *, 'obtuse triangle' ELSE IF(angleAmeasure == 'a' .AND. angleBmeasure == 'a' .AND. angleCmeasure == 'a')THEN PRINT *, 'acute triangle' END IF ! end 180 chceck END IF !end classification END IF !end sub5program = 1 ELSE IF(selected5subProgram == 2)THEN WRITE(*,'(A)') 'enter the first side measure, `a`' READ(*,*) sideA WRITE(*,'(A)') 'enter the second side measure, `b`' READ(*,*) sideB WRITE(*,'(A)') 'enter the third side measure, `c`' READ(*,*) sideC PRINT *, sideA, sideB, sideC !fix, no output after entering sides IF(sideA == sideB .AND. sideB == sideC .AND. sideA == sideC)THEN PRINT *, 'equilateral triangle' ELSE IF(sideA == sideB .OR. sideB == sideC)THEN PRINT *, 'isosceles triangle' ELSE IF(sideA /= sideB .AND. sideB /= sideC .AND. sideA /= sideC)THEN PRINT *, 'scalene triangle' END IF ELSE IF(selected1program == 6)THEN PRINT *, '1 - combined gas law' PRINT *, '2 - ideal gas law' READ (*,*) selectedScienceProgram v1 = 0 v2 = 0 p1 = 0 p2 = 0 t1 = 0 t2 = 0 IF(selectedScienceProgram == 1)THEN PRINT *, 'combined gas law:' PRINT *, 'p1*v1/t1 = p2*v2/t2' PRINT *, 'what variable is unknown?' PRINT *, '(p1, p2, v1, v2, t1, t2)' PRINT *, 'WORK IN PROGRESS' READ(*,*) unknownVar !p*v/t READ (*,*) p1, v1, t1, p2, v2, t2 PRINT *, p1, v1, t1, p2, v2, t2 ELSE IF(selectedScienceProgram == 2)THEN !PV = nRT PRINT *, 'ideal gas law:' PRINT *, 'PV = nRT' PRINT *, 'required units: ' PRINT *, 'V = litres' PRINT *, 'P = atmospheres' PRINT *, 'n = mols' PRINT *, 'T = kelvin' PRINT *, 'enter the unknown variable' READ (*,*) unknownVar gasFinalNum = 0 IF(unknownVar == 'V')THEN !P?=nRT PRINT *, 'enter the value of P' READ (*,*) P PRINT *, 'enter the value of n' READ (*,*) gasN PRINT *, 'enter the value of T' READ (*,*) T gasFinalNum = (gasN*0.0821*T) / (P) WRITE(*,'(A,G0,A)') 'the volume of this gas is ', gasFinalNum, 'L' ELSE IF(unknownVar == 'P')THEN !?V=nRT PRINT *, 'enter the value of V' READ (*,*) V PRINT *, 'enter the value of n' READ (*,*) gasN PRINT *, 'enter the value of T' READ (*,*) T gasFinalNum = (gasN*0.0821*T) / (V) WRITE(*,'(A,G0,A)') 'the pressure of this gas is ', gasFinalNum, ' atmospheres' ELSE IF(unknownVar == 'n')THEN !PV=?RT PRINT *, 'enter the value of P' READ (*,*) P PRINT *, 'enter the value of V' READ (*,*) V PRINT *, 'enter the value of T' READ (*,*) T gasFinalNum = (0.0821*T) / (P * V) WRITE(*,'(A,G0,A)') 'the of this gas is ', gasFinalNum, ' ' !check ELSE IF(unknownVar == 'T')THEN !pv=nr? PRINT *, 'enter the value of P' READ (*,*) P PRINT *, 'enter the value of V' READ (*,*) V PRINT *, 'enter the value of n' READ (*,*) gasN gasFinalNum = (gasN * 0.0821) / (P * V) WRITE(*,'(A,G0,A)') 'the temperature of this gas is ', gasFinalNum, ' kelvin' !check ELSE PRINT *, 'invalid input' END IF END IF !end selectedscienceprogram ! format, x - x | x x - x etc ELSE IF(selected1Program == 7) THEN PRINT *, 'enter the number you would like to start with' PRINT *, 'DO NOT go over 2,147,483,645' PRINT *, '(maximum steps: 1000)' READ *, cc1 cc2 = cc1 cc3 = cc1 DO n = 1, 1000 ! cc3 = highest IF(cc1 > cc3)THEN cc3 = cc1 END IF IF (MOD(cc1,2) .EQ. 0) THEN !even IF(cc1 == 1)THEN WRITE(*,'(A)') '----------' WRITE(*,'(A)') 'ending sequence, stuck in 4-2-1 loop' WRITE(*,'(A)') 'STATS:' WRITE(*,'(A,I0)') 'starting number: ', cc2 WRITE(*,'(A,I0)') 'cyle counts: ', n EXIT END IF cc1 = cc1 / 2 PRINT *, cc1 ELSE IF(cc1 == 1)THEN WRITE(*,'(A)') '----------' WRITE(*,'(A)') 'ending sequence, stuck in 4-2-1 loop' WRITE(*,'(A)') 'STATS:' WRITE(*,'(A,I0)') 'largest number reached: ', cc3 WRITE(*,'(A,I0)') 'starting number: ', cc2 WRITE(*,'(A,I0)') 'cyle counts: ', n EXIT END IF !odd cc1 = (cc1 * 3) + 1 PRINT *, cc1 END IF END DO ELSE IF(selected1Program == 8) THEN !interest !intr1, intr2, intr3 PRINT *, 'enter your starting amount' READ (*,*) intr1 PRINT *, 'what is the interest rate?' READ (*,*) intrRate PRINT *, 'simple or compound interest?' READ (*,*) intrType PRINT *, 'how many terms would you like to calculate?' READ (*,*) intr2 IF(intrType == 'simple' .OR. intrType == 'Simple') THEN !(r*b*m)/n !(intrRate*intr1*intr2)/ !i = prt PRINT *, 'monthly or yearly?' READ (*,*) intrIntv intr3 = (intr1)*(intrRate / 100)*intr2 IF(intrIntv == 'monthly' .OR. intrIntv == 'Monthly') THEN WRITE(*,'(A)') 'results:' WRITE(*,'(A,G0)') 'starting amount: ', intr1 WRITE(*,'(A,G0)') 'interest rate: ', intrRate WRITE(*,'(A,G0)') 'interest owed/made: ', intr3 WRITE(*,'(A,G0,A,G0)') 'at the end of ', intr2, ' months, you will owe/have a total of ', (intr1 + intr3) ELSE IF(intrIntv == 'yearly' .OR. intrIntv == 'Yearly') THEN WRITE(*,'(A)') 'results:' WRITE(*,'(A,G0)') 'starting amount: ', intr1 WRITE(*,'(A,G0)') 'interest rate: ', intrRate WRITE(*,'(A,G0)') 'interest owed/made: ', intr3 WRITE(*,'(A,G0,A,G0)') 'at the end of ', intr2, ' years, you will owe/have a total of ', (intr1 + intr3) END IF ELSE IF(intrType == 'compound' .OR. intrType == 'Compound') THEN !A = P(1 + r/n)**nt PRINT *, 'how many times does the amount compound per year?' READ (*,*) intr4 intr3 = intr1*(1 + ((intrRate / 100) / intr4))**(intr4 * intr2) WRITE(*,'(A)') 'results:' WRITE(*,'(A,G0)') 'starting amount: ', intr1 WRITE(*,'(A,G0)') 'interest rate: ', intrRate WRITE(*,'(A,G0)') 'interest owed/made: ', (intr3 - intr1) WRITE(*,'(A,G0,A,G0)') 'at the end of ', intr2, ' terms, you will owe/have a total of ', intr3 END IF !end intrType !For even numbers, divide by 2; !For odd numbers, multiply by 3 and add 1. END IF !end selected1program ELSE IF (selectedProgram == 2) THEN PRINT *, 'what would you like to convert?' PRINT *, '1 - temperatures' PRINT *, '2 - units of measurement' PRINT *, '3 - empty' READ(*,*) selected3program IF(selected3program == 1) THEN PRINT *, 'enter the temperature you want to convert' READ (*,*) temp1 PRINT *, 'what unit is that temperature in? (UPPERCASE)' PRINT *, 'F, C, K, R' READ (*,*) temp1unit IF(temp1unit == 'F') THEN temp2c = (temp1 - 32) * 5/9 !F to C temp2k = (temp1 - 32) * 5/9 + 273.15 !F to K temp2r = (temp1 + 459.67) !F to R ELSE IF(temp1unit == 'C') THEN temp2f = (temp1 * 9/5) + 32 !C to F temp2k = temp1 + 273.15 !C to K temp2r = temp1 * 9/5 + 491.67 !C to R ELSE IF(temp1unit == 'K') THEN temp2c = temp1 - 273.15 !K to C temp2f = (temp1 - 273.15) * 9/5 + 32 !K to F temp2r = temp1 * 1.8 !K to R ELSE IF(temp1unit == 'R') THEN temp2c = (temp1 - 491.67) * 5/9 !R to C temp2k = temp1 * 5/9 !R to K temp2f = temp1 - 459.67 !R to F END IF WRITE(*,'(A,I0,A)') 'your initial temperature was: ', temp1, temp1unit PRINT *, 'below are your conversions' IF(temp1unit == 'C') THEN WRITE(*,'(I0,A)') temp2f, 'F' WRITE(*,'(I0,A)') temp2k, 'K' WRITE(*,'(I0,A)') temp2r, 'R' ELSE IF(temp1unit == 'F') THEN WRITE(*,'(I0,A)') temp2c, 'C' WRITE(*,'(I0,A)') temp2k, 'K' WRITE(*,'(I0,A)') temp2r, 'R' ELSE IF(temp1unit == 'K') THEN WRITE(*,'(I0,A)') temp2f, 'F' WRITE(*,'(I0,A)') temp2c, 'C' WRITE(*,'(I0,A)') temp2r, 'R' ELSE IF(temp1unit == "R") THEN WRITE(*,'(I0,A)') temp2f, 'F' WRITE(*,'(I0,A)') temp2c, 'C' WRITE(*,'(I0,A)') temp2k, 'K' END IF ELSE IF(selected3program == 2) THEN PRINT *, 'what are you converting?' PRINT *, '1 - length (ns)' PRINT *, '2 - volume (ns)' PRINT *, '3 - time' READ (*,*) selected3subprogram IF(selected3subprogram == 1) THEN !length ELSE IF (selected3subprogram == 2) THEN !volume ELSE IF (selected3subprogram == 3) THEN PRINT *, 'what is your base unit?' PRINT *, '1 - seconds' PRINT *, '2 - minutes' PRINT *, '3 - hours' PRINT *, '4 - days' PRINT *, '5 - weeks' PRINT *, '6 - months' PRINT *, '7 - years' READ(*,*) baseUnit PRINT *, 'enter the desired time' READ(*,*) baseValue PRINT *, 'what do you want to convert that into?' PRINT *, '1 - seconds' PRINT *, '2 - minutes' PRINT *, '3 - hours' PRINT *, '4 - days' PRINT *, '5 - weeks' PRINT *, '6 - months' PRINT *, '7 - years' READ (*,*) desiredUnit IF(baseUnit == 1) THEN !base unit seconds baseValue = baseValue ELSE IF(baseUnit == 2) THEN ! minutes baseValue = baseValue * 60 ELSE IF(baseUnit == 3) THEN ! hours baseValue = baseValue * 60 * 60 ELSE IF(baseUnit == 4) THEN ! days baseValue = baseValue * 60 * 60 * 24 ELSE IF(baseUnit == 5) THEN ! weeks baseValue = baseValue * 60 * 60 * 24 * 7 ELSE IF(baseUnit == 6) THEN ! months baseValue = baseValue * 60 * 60 * 24 * 7 * 7.5 ELSE IF(baseUnit == 7) THEN ! years baseValue = baseValue * 60 * 60 * 24 * 7 * 7.5 * 12 END IF IF(desiredUnit == 1) THEN !base unit seconds WRITE(*, '(I0,A)') baseValue, ' seconds' ELSE IF(desiredUnit == 2) THEN ! minutes WRITE(*, '(I0,A)') baseValue / 60, ' minutes' ELSE IF(desiredUnit == 3) THEN ! hours WRITE(*, '(I0,A)') baseValue / 60 / 60, ' hours' ELSE IF(desiredUnit == 4) THEN ! days WRITE(*, '(I0,A)') baseValue / 60 / 60 / 24, ' days' ELSE IF(desiredUnit == 5) THEN ! weeks WRITE(*, '(I0,A)') baseValue / 60 / 60 / 24 / 7, ' weeks' ELSE IF(desiredUnit == 6) THEN ! months WRITE(*, '(I0,A)') baseValue / 60 / 60 / 24 / 7 / 7.5, ' months' ELSE IF(desiredUnit == 7) THEN ! years WRITE(*, '(I0,A)') baseValue / 60 / 60 / 24 / 7 / 7.5 / 12 ,' years' END IF IF(debugMode == 1) THEN PRINT *, 'END CONVERSIONS' PRINT *, uSeconds PRINT *, unitM PRINT *, unitH PRINT *, unitD PRINT *, unitW PRINT *, unitMo PRINT *, unitY END IF END IF !end selected3SUBpprogram END IF !end selected3program END IF !idk what this does, but without it the code breaks IF (selectedProgram == 3) THEN !sorting algorithm WRITE(*, '(A)') 'this algorithm will sort what you input in least to greatest format' WRITE(*, '(A)') 'enter 5 numbers seperated by commas (ex: 1,2,5,6,7)' READ(*,*) sort1, sort2, sort3 WRITE(*, '(A)') 'sorting...' DO n = 1, 10 WRITE(*, '(I0,A,I0,A,I0,A,I0,A,I0)') sort1final,' ', sort2final,' ', sort3final !db IF(sort1 < sort2 .AND. sort2 < sort3)THEN PRINT *, 'the numbers you input were already sorted least to greatest' ELSE PRINT *, 'nah we gotta go deeper' !db END IF IF(sort1 > sort2)THEN sort1final = sort2 sort2final = sort1 END IF END DO END IF ! ending program 3 IF (selectedProgram == 4) THEN !card deck !club diamond heart spade PRINT *, 'enter a number and suit of a card to display (ex: 5 spade)' READ (*,*) cardNum, cardSuit PRINT *, cardNum PRINT *, cardSuit ! ◆ ♣ ♥ ♠ ! 8 spaces IF(cardSuit == 'club' .OR. cardSuit == 'clubs')THEN suitIcon = 'C' ELSE IF(cardSuit == 'diamond' .OR. cardSuit == 'diamonds')THEN suitIcon = 'D' ELSE IF(cardSuit == 'heart' .OR. cardSuit == 'hearts')THEN suitIcon = 'H' ELSE IF(cardSuit == 'spade' .OR. cardSuit == 'spades')THEN suitIcon = 'S' END IF IF(cardNum == 1)THEN suitGraphic1 = ' ' suitGraphic2 = ' '//suitIcon//' ' suitGraphic3 = ' ' ELSE IF(cardNum == 2)THEN suitGraphic1 = ' '//suitIcon//' ' suitGraphic2 = ' ' suitGraphic3 = ' '//suitIcon//' ' ELSE IF(cardNum == 3)THEN suitGraphic1 = ' '//suitIcon//' ' suitGraphic2 = ' '//suitIcon//' ' suitGraphic3 = ' '//suitIcon//' ' ELSE IF(cardNum == 4)THEN suitGraphic1 = ' '//suitIcon//' '//suitIcon//' ' suitGraphic2 = ' ' suitGraphic3 = ' '//suitIcon//' '//suitIcon//' ' ELSE IF(cardNum == 5)THEN suitGraphic1 = ' '//suitIcon//' '//suitIcon//' ' suitGraphic2 = ' '//suitIcon//' ' suitGraphic3 = ' '//suitIcon//' '//suitIcon//' ' ELSE IF(cardNum == 6)THEN suitGraphic1 = ' '//suitIcon//' '//suitIcon//' ' suitGraphic2 = ' '//suitIcon//' '//suitIcon//' ' suitGraphic3 = ' '//suitIcon//' '//suitIcon//' ' ELSE IF(cardNum == 7)THEN suitGraphic1 = ' '//suitIcon//' '//suitIcon//' ' suitGraphic2 = ' '//suitIcon//' '//suitIcon//' '//suitIcon//' ' suitGraphic3 = ' '//suitIcon//' '//suitIcon//' ' ELSE IF(cardNum == 8)THEN suitGraphic1 = ' '//suitIcon//' '//suitIcon//' '//suitIcon//' ' suitGraphic2 = ' '//suitIcon//' '//suitIcon//' ' suitGraphic3 = ' '//suitIcon//' '//suitIcon//' '//suitIcon//' ' ELSE IF(cardNum == 9)THEN suitGraphic1 = ' '//suitIcon//' '//suitIcon//' '//suitIcon//' ' suitGraphic2 = ' '//suitIcon//' '//suitIcon//' '//suitIcon//' ' suitGraphic3 = ' '//suitIcon//' '//suitIcon//' '//suitIcon//' ' END IF !subroutine WRITE(*, '(A)') '----------' WRITE(*, '(A,I0,A)') '|',cardNum,' |' WRITE(*, '(A,A,A)') '|',suitGraphic1,'|' WRITE(*, '(A,A,A)') '|',suitGraphic2,'|' WRITE(*, '(A,A,A)') '|',suitGraphic3,'|' WRITE(*, '(A,I0,A)') '| ',cardNum,'|' WRITE(*, '(A)') '----------' !end subroutine END IF ! ending program 4 IF (selectedProgram == 5) THEN CALL gamblingUI END IF ! ending program 5 IF (selectedProgram == 6) THEN PRINT *, '1 - fibonacci sequence' PRINT *, '2 - multiplication table' PRINT *, '3 - random number guessing thing' PRINT *, '4 - D&D dice roller' PRINT *, '5 - magic 8 ball' PRINT *, '6 - rock paper scissors' PRINT *, '7 - tic tac toe' PRINT *, '8 - ascii art maker' READ (*,*) selected6Program IF(selected6Program == 1) THEN f = 0 f1 = 0 f2 = 1 DO n = 1, 50 f = f1 + f2 PRINT *, f f2 = f1 f1 = f CALL SLEEP(1) IF(f == 1134903170) THEN f = f1 + f2 PRINT *, f f2 = f1 f1 = f PRINT *, 'any number past this point will cause a fatal error, ending sequence' EXIT END IF END DO ELSE IF(selected6Program == 2) THEN PRINT *, 'enter the number you would like to see the multiplication table for' READ (*,*) extraVar DO n = 1, 20 g = 1 WRITE(*, '(I0,A,I0,A,I0)') extraVar, ' * ', n, ' = ', extravar * n g = g +1 END DO ELSE IF(selected6Program == 3) THEN remainingGuesses = 10 CALL random_number(rNum) rngResult = INT(rNum * 99) + 1 IF(debugMode == 1) THEN PRINT *, 'debug: rngResult: ', rngResult END IF DO PRINT *, '---------------------------' PRINT *, ' the number is between 0 and 100' WRITE(*, '(A,I0)') 'guesses remaining:', remainingGuesses PRINT *, 'enter your guess' READ (*,*) enteredGuess PRINT *, ' ' IF(enteredGuess == rngResult) THEN PRINT *, 'WIN' WRITE(*, '(A,I0,A)') 'this took you ', (10-remainingGuesses), ' guesses!' EXIT ELSE IF(enteredGuess > rngResult) THEN PRINT *, 'lower' PRINT *, ' ' remainingGuesses = remainingGuesses-1 ELSE IF(enteredGuess < rngResult) THEN PRINT *, 'higher' PRINT *, ' ' remainingGuesses = remainingGuesses-1 END IF IF (remainingGuesses == 0) THEN WRITE(*, '(A,I0)') 'lose, the number was:', rngResult EXIT END IF END DO ELSE IF(selected6program == 4) THEN !4 6 8 10 12 20 100 PRINT *, 'what die would you like to roll?' PRINT *, '4, 6, 8, 10, 12, 20, 100' READ (*,*) selectedDiceRoll !roll dice WRITE(*, '(A,I0,A)') 'how many ', selectedDiceRoll, ' sided dice would you like to roll?' READ (*,*) extraVar IF(debugMode == 1) THEN PRINT *, 'debug:', extraVar END IF WRITE(*,'(A,I0,A,I0,A)') 'your ', extraVar, ' ', selectedDiceRoll, ' sided dice have landed' DO n = 1, extraVar CALL random_number(rNum) rngResult = INT(rNum * selectedDiceRoll) + 1 PRINT *, rngResult END DO PRINT *, ' ' PRINT *, '1 - roll again' PRINT *, '2 - EXIT' READ(*,*) extraVar IF(extraVar == 1)THEN CALL rollDice END IF ELSE IF(selected6Program == 5)THEN PRINT *, '~~enter your question, the magic 8 ball shall answer~~' READ(*,*) CALL random_number(rNum) rngResult = INT(rNum * 20) + 1 IF(debugMode == 1) THEN PRINT *, rngResult END IF PRINT *, '~~the magic 8 ball is thinking~~' PRINT *, ' ' CALL SLEEP(1) PRINT *, '~~the magic 8 ball has spoken~~' IF(rngResult == 1) THEN PRINT *, '~~the magic 8 ball has spoken~~' PRINT *, 'it is certain ' ELSE IF(rngResult == 2) THEN PRINT *, 'it is decidedly so' ELSE IF(rngResult == 3) THEN PRINT *, 'without a doubt' ELSE IF(rngResult == 4) THEN PRINT *, 'yes definitely' ELSE IF(rngResult == 5) THEN PRINT *, 'you may rely on it' ELSE IF(rngResult == 6) THEN PRINT *, 'as I see it, yes' ELSE IF(rngResult == 7) THEN PRINT *, 'most likely' ELSE IF(rngResult == 8) THEN PRINT *, 'outlook good' !no its not ELSE IF(rngResult == 9) THEN PRINT *, 'yes' ELSE IF(rngResult == 10) THEN PRINT *, 'signs point to yes' ! ^ positive ! v negative ELSE IF(rngResult == 11) THEN PRINT *, 'don`t count on it' ELSE IF(rngResult == 12) THEN PRINT *, 'my reply is no' ELSE IF(rngResult == 13) THEN PRINT *, 'my sources say no' ELSE IF(rngResult == 14) THEN PRINT *, 'outlook not so good' !yeah better, gmail.com ELSE IF(rngResult == 15) THEN PRINT *, 'very doubtful' !^ negative !v noncommital ELSE IF(rngResult == 16) THEN PRINT *, 'reply hazy, try again' ELSE IF(rngResult == 17) THEN PRINT *, 'ask again later' ELSE IF(rngResult == 18) THEN PRINT *, 'better not tell you now' ELSE IF(rngResult == 19) THEN PRINT *, 'cannot predict now' ELSE IF(rngResult == 20) THEN PRINT *, 'concentrate and ask again' END IF !ending 8 ball responses ELSE IF(selected6Program == 6) THEN PRINT *, 'make your descision' PRINT *, '1 - rock' PRINT *, '2 - paper' PRINT *, '3 - scissors' READ (*,*) rpsBet CALL SLEEP(1) PRINT *, 'rock...' CALL SLEEP(1) PRINT *, 'paper...' CALL SLEEP(1) PRINT *, 'scissors...' CALL SLEEP(1) PRINT *, 'SHOOT!' CALL random_number(rNum) rngResult = INT(rNum * 3) + 1 IF(debugMode == 1) THEN PRINT *, rngResult END IF PRINT *, ' ' IF(rngResult == 1) THEN !rock PRINT *, 'the computer picked rock' ELSE IF(rngResult == 2) THEN !paper PRINT *, 'the computer picked paper' ELSE IF(rngResult == 3) THEN !scissors PRINT *, 'the computer picked scissors' END IF !end rps response IF(rngResult == 1) THEN IF(rpsBet == 1) THEN PRINT *, "you picked the same thing, you've tied!" ELSE IF(rpsBet == 2) THEN PRINT *, "you win!" ELSE IF(rpsBet == 3) then PRINT *, "you lose, try again" END IF ELSE IF(rngResult == 2) THEN IF(rpsBet == 1) THEN PRINT *, "you lose, try again" ELSE IF(rpsBet == 2) THEN PRINT *, "you picked the same thing, you've tied!" ELSE IF(rpsBet == 3) then PRINT *, "you win!" END IF ELSE IF(rngResult == 3) THEN IF(rpsBet == 1) THEN PRINT *, "you win!" ELSE IF(rpsBet == 2) THEN PRINT *, "you lose, try again" ELSE IF(rpsBet == 3) then PRINT *, "you picked the same thing, you've tied!" END IF END IF ELSE IF(selected6Program == 7) THEN ! topL, topM, topR ! midL, midM, midR ! botL, botM, botR PRINT *, 'welcome to tic tac toe!' PRINT *, 'this is a two player game, at the top of the screen there will be' PRINT *, 'an indicator telling whos turn it is' PRINT *, 'player 1 will be X, player 2 will be O' PRINT *, 'if you choose a number not on the board, your turn will be skipped' ticTacToeGame = 1 DO n=1, 9 IF(ticTacToeGame == 1)THEN WRITE(*,'(A,A,A,A,A)') topL, '|', topM, "|", topR WRITE(*,'(A)') '-----' WRITE(*,'(A,A,A,A,A)') midL, '|', midM, "|", midR WRITE(*,'(A)') '-----' WRITE(*,'(A,A,A,A,A)') botL, '|', botM, "|", botR END IF IF(topL == 'X' .AND. topM == 'X' .AND. topR == 'X' .OR. topL == 'O' .AND. topM == 'O' .AND. topR == 'O') THEN PRINT *, 'WIN : top row' ticTacToeGame = 2 ELSE IF(midL == 'X' .AND. midM == 'X' .AND. midR == 'X' .OR. midL == 'O' .AND. midM == 'O' .AND. midR == 'O') THEN PRINT *, 'WIN : middle row' ticTacToeGame = 2 ELSE IF(botL == 'X' .AND. botM == 'X' .AND. botR == 'X' .OR. botL == 'O' .AND. botM == 'O' .AND. botR == 'O') THEN PRINT *, 'WIN : bottom row' ticTacToeGame = 2 ELSE IF(topL == 'X' .AND. midL == 'X' .AND. botL == 'X' .OR. topL == 'O' .AND. midL == 'O' .AND. botL == 'O') THEN PRINT *, 'WIN : left column' ticTacToeGame = 2 ELSE IF(topM == 'X' .AND. midM == 'X' .AND. botM == 'X' .OR. topM == 'O' .AND. midM == 'O' .AND. botM == 'O') THEN PRINT *, 'WIN : middle column' ticTacToeGame = 2 ELSE IF(topR == 'X' .AND. midR == 'X' .AND. botR == 'X' .OR. topR == 'O' .AND. midR == 'O' .AND. botR == 'O') THEN PRINT *, 'WIN : right column' ticTacToeGame = 2 ELSE IF(topL == 'X' .AND. midM == 'X' .AND. botR == 'X' .OR. topL == 'O' .AND. midM == 'O' .AND. botR == 'O') THEN PRINT *, 'WIN : top left to bottom right' ticTacToeGame = 2 ELSE IF(topR == 'X' .AND. midM == 'X' .AND. botL == 'X' .OR. topR == 'O' .AND. midM == 'O' .AND. botL == 'O') THEN PRINT *, 'WIN : top right to bottom left' ticTacToeGame = 2 END IF IF(ticTacToeGame == 1)THEN PRINT *, ' ' PRINT *, 'it is player 1`s turn' playerToken = 'X' PRINT *, ' ' PRINT *, 'enter the number of the space you would like to place your X at' READ(*,*) extraVar PRINT *, ' ' IF(extraVar == 1) THEN IF(topL == '1') THEN topL = playerToken END IF ELSE IF(extraVar == 2) THEN IF(topM == '2') THEN topM = playerToken END IF ELSE IF(extraVar == 3) THEN IF(topR == '3') THEN topR = playerToken END IF ELSE IF(extraVar == 4) THEN IF(midL == '4') THEN midL = playerToken END IF ELSE IF(extraVar == 5) THEN IF(midM == '5') THEN midM = playerToken END IF ELSE IF(extraVar == 6) THEN IF(midR == '6') THEN midR = playerToken END IF ELSE IF(extraVar == 7) THEN IF(botL == '7') THEN botL = playerToken END IF ELSE IF(extraVar == 8) THEN IF(botM == '8') THEN botM = playerToken END IF ELSE IF(extraVar == 9) THEN IF(botR == '9') THEN botR = playerToken END IF END IF END IF ! end ticTacToeGame IF(ticTacToeGame == 2)THEN PRINT *, '2 detected' RETURN END IF IF(ticTacToeGame == 1)THEN WRITE(*,'(A,A,A,A,A)') topL, '|', topM, "|", topR WRITE(*,'(A)') '-----' WRITE(*,'(A,A,A,A,A)') midL, '|', midM, "|", midR WRITE(*,'(A)') '-----' WRITE(*,'(A,A,A,A,A)') botL, '|', botM, "|", botR END IF IF(topL == 'X' .AND. topM == 'X' .AND. topR == 'X' .OR. topL == 'O' .AND. topM == 'O' .AND. topR == 'O') THEN PRINT *, 'WIN : top row' ticTacToeGame = 2 ELSE IF(midL == 'X' .AND. midM == 'X' .AND. midR == 'X' .OR. midL == 'O' .AND. midM == 'O' .AND. midR == 'O') THEN PRINT *, 'WIN : middle row' ticTacToeGame = 2 ELSE IF(botL == 'X' .AND. botM == 'X' .AND. botR == 'X' .OR. botL == 'O' .AND. botM == 'O' .AND. botR == 'O') THEN PRINT *, 'WIN : bottom row' ticTacToeGame = 2 ELSE IF(topL == 'X' .AND. midL == 'X' .AND. botL == 'X' .OR. topL == 'O' .AND. midL == 'O' .AND. botL == 'O') THEN PRINT *, 'WIN : left column' ticTacToeGame = 2 ELSE IF(topM == 'X' .AND. midM == 'X' .AND. botM == 'X' .OR. topM == 'O' .AND. midM == 'O' .AND. botM == 'O') THEN PRINT *, 'WIN : middle column' ticTacToeGame = 2 ELSE IF(topR == 'X' .AND. midR == 'X' .AND. botR == 'X' .OR. topR == 'O' .AND. midR == 'O' .AND. botR == 'O') THEN PRINT *, 'WIN : right column' ticTacToeGame = 2 ELSE IF(topL == 'X' .AND. midM == 'X' .AND. botR == 'X' .OR. topL == 'O' .AND. midM == 'O' .AND. botR == 'O') THEN PRINT *, 'WIN : top left to bottom right' ticTacToeGame = 2 ELSE IF(topR == 'X' .AND. midM == 'X' .AND. botL == 'X' .OR. topR == 'O' .AND. midM == 'O' .AND. botL == 'O') THEN PRINT *, 'WIN : top right to bottom left' ticTacToeGame = 2 END IF IF(ticTacToeGame == 1)THEN PRINT *, ' ' PRINT *, 'it is player 2`s turn' playerToken = 'O' PRINT *, ' ' PRINT *, 'enter the number of the space you would like to place your O at' READ(*,*) extraVar PRINT *, ' ' IF(extraVar == 1) THEN IF(topL == '1') THEN topL = playerToken END IF ELSE IF(extraVar == 2) THEN IF(topM == '2') THEN topM = playerToken END IF ELSE IF(extraVar == 3) THEN IF(topR == '3') THEN topR = playerToken END IF ELSE IF(extraVar == 4) THEN IF(midL == '4') THEN midL = playerToken END IF ELSE IF(extraVar == 5) THEN IF(midM == '5') THEN midM = playerToken END IF ELSE IF(extraVar == 6) THEN IF(midR == '6') THEN midR = playerToken END IF ELSE IF(extraVar == 7) THEN IF(botL == '7') THEN botL = playerToken END IF ELSE IF(extraVar == 8) THEN IF(botM == '8') THEN botM = playerToken END IF ELSE IF(extraVar == 9) THEN IF(botR == '9') THEN botR = playerToken END IF END IF END IF !end tictactoegame IF(ticTacToeGame == 2)THEN RETURN END IF !check END DO ELSE IF(selected6program == 8)THEN aLine0 = ' ' DO WRITE(*, '(A)') 'type the number of the line you would like to edit' PRINT *, ' ' WRITE(*, '(A,A)') '1. ', aLine0 WRITE(*, '(A,A)') '2. ', aLine1 WRITE(*, '(A,A)') '3. ', aLine2 WRITE(*, '(A,A)') '4. ', aLine3 WRITE(*, '(A,A)') '5. ', aLine4 WRITE(*, '(A,A)') '6. ', aLine5 WRITE(*, '(A)') '7 - save as' WRITE(*, '(A)') '8 - open' READ(*,*) selectedAline IF(selectedAline == 1)THEN WRITE(*, '(A)') aLine0 READ (*,'(A)') aLine0 ELSE IF(selectedAline == 2)THEN WRITE(*, '(A)') aLine1 READ (*,'(A)') aLine1 ELSE IF(selectedAline == 3)THEN WRITE(*, '(A)') aLine2 READ (*,'(A)') aLine2 ELSE IF(selectedAline == 4)THEN WRITE(*, '(A)') aLine3 READ (*,'(A)') aLine3 ELSE IF(selectedAline == 5)THEN WRITE(*, '(A)') aLine4 READ (*,'(A)') aLine4 ELSE IF(selectedAline == 6)THEN WRITE(*, '(A)') aLine5 READ (*,'(A)') aLine5 ELSE IF(selectedAline == 7)THEN WRITE(*, '(A)') 'name this save file' READ(*,*) saves(i) PRINT *, 'save', i, saves(i) save1 = aLine0 // CHAR(10) // aLine1 // CHAR(10) // aLine2 // CHAR(10) // aLine3 // CHAR(10) // aLine4 // CHAR(10) // aLine5 WRITE(*, '(A,A)') 'data saved to ', currentSave ELSE IF(selectedAline == 8)THEN WRITE(*, '(A)') 'select the file you want to display' DO i = 1, 10 WRITE(*, '(A)') '1 - ', saves(i) END DO !etc READ(*,*) selectedDisplay IF(selectedDisplay == 1)THEN WRITE(*, '(A)') TRIM(adjustl(save1)) ELSE IF(selectedDisplay == 2)THEN WRITE(*, '(A)') TRIM(adjustl(save2)) END IF ELSE IF(selectedAline == 0)THEN aLine0 = 'line 1' aLine1 = 'line 2' aLine2 = 'line 3' aLine3 = 'line 4' aLine4 = 'line 5' aLine5 = 'line 6' END IF END DO END IF !end selected6program END IF ! end program 6 !IF(selectedProgram == 7)THEN !etc. !END IF ! ------- END ------- PRINT *, ' ' PRINT *, 'press ENTER to restart' READ (*,*) PRINT *, '////////////////////END\\\\\\\\\\\\\\\\\\\\' DO n = 1, 75 ! do 75 times in increments of 1 starting from 0 ending at 75 PRINT *, ' ' END DO PRINT *, '-------------------------Welcome to sOS-------------------------' END DO !danger zone PRINT *, 'youre not supposed to see this, what`d i mess up?' END PROGRAM hello SUBROUTINE display(balance) INTEGER :: balance PRINT *, '-------------------' WRITE(*, '(A,I0)') 'balance: ', balance PRINT *, '-------------------' END SUBROUTINE display RECURSIVE SUBROUTINE rollDice INTEGER :: n, rngResult INTEGER :: currentBet REAL :: rNum INTEGER :: debugMode INTEGER :: selectedDiceRoll INTEGER :: extraInt, extraVar PRINT *, 'what die would you like to roll?' PRINT *, '4, 6, 8, 10, 12, 20, 100' READ (*,*) selectedDiceRoll !roll dice WRITE(*, '(A,I0,A)') 'how many ', selectedDiceRoll, ' sided dice would you like to roll?' READ (*,*) extraVar IF(debugMode == 1) THEN PRINT *, 'debug:', extraVar END IF WRITE(*,'(A,I0,A,I0,A)') 'your ', extraVar, ' ', selectedDiceRoll, ' sided dice have landed' DO n = 1, extraVar CALL random_number(rNum) rngResult = INT(rNum * selectedDiceRoll) + 1 PRINT *, rngResult END DO PRINT *, ' ' PRINT *, '1 - roll again' PRINT *, '2 - EXIT' READ(*,*) extraVar IF(extraVar == 1)THEN CALL rollDice END IF END SUBROUTINE rollDice subroutine midpointFind(x1, x2, y1, y2, mpFoundX, mpFoundY) IMPLICIT NONE REAL :: x1, x2, y1, y2, mpFoundX, mpFoundY PRINT *, 'enter your x1' READ (*,*) x1 PRINT *, 'enter your x2' READ (*,*) x2 PRINT *, 'enter your y1' READ (*,*) y1 PRINT *, 'enter your y2' READ (*,*) y2 mpFoundX = ((x1 + x2)/2) mpFoundY = ((y1 + y2)/2) end subroutine RECURSIVE subroutine gamblingUI IMPLICIT NONE REAL :: selectedGamblingGame !REAL, INTENT(INOUT) :: balance PRINT *, '-------------------------Lets Go Gambling!----------------------' PRINT *, '1 - roulette' PRINT *, '2 - blackjack' PRINT *, '3 - exit' READ (*,*) selectedGamblingGame IF(selectedGamblingGame == 1) THEN CALL rouletteGame ELSE IF(selectedGamblingGame == 2) THEN CALL blackjackGame ELSE IF(selectedGamblingGame == 3) THEN RETURN END IF CALL SLEEP(1) CALL gamblingUI end subroutine ! ---------------------------------------------------------------- subroutine rouletteGame IMPLICIT NONE INTEGER :: currentBet, rouletteBet REAL :: rNum INTEGER :: rngResult INTEGER :: balance = 500 balance = balance CALL display(balance) PRINT *, 'how much would you like to bet?' READ (*,*) currentBet PRINT *, 'what are you betting on?' PRINT *, '1 - black (50%)' PRINT *, '2 - red (50%)' READ (*,*) rouletteBet IF(rouletteBet == 1) THEN WRITE(*, '(A,I0,A)') 'bet of ', currentBet, ' placed on black' ELSE IF(rouletteBet == 2) THEN WRITE(*, '(A,I0,A)') 'bet of ', currentBet, ' placed on red' END IF balance = balance - currentBet CALL display(balance) PRINT *, '*spinning*' PRINT *, ' ' CALL SLEEP(3) !make function, RNG CALL random_number(rNum) rngResult = INT(rNum * 2) + 1 !make function, RNG IF(rngResult == 1) THEN !black finish PRINT *, 'the ball has landed on BLACK' PRINT *, ' ' IF(rouletteBet == 1) THEN !black bet PRINT *, 'WIN' balance = balance + (currentBet*2) CALL display(balance) END IF IF(rouletteBet == 2) THEN !red bet PRINT *, 'LOSE' CALL display(balance) END IF END IF IF(rngResult == 2) THEN !red finish PRINT *, 'the ball has landed on RED' PRINT *, ' ' IF(rouletteBet == 1) THEN !black bet PRINT *, 'LOSE' CALL display(balance) END IF ELSE IF(rouletteBet == 2) THEN !red bet PRINT *, 'WIN' balance = balance + (currentBet*2) CALL display(balance) END IF end subroutine subroutine blackjackGame IMPLICIT NONE REAL :: currentBet, rouletteBet, rNum INTEGER :: rngResult, randomCard1, randomCard2, randomCard3, randomCard4, randomCard5, randomCard6 INTEGER :: balance = 500 CHARACTER :: blackjackHorS balance = balance PRINT *, '-=-=-=-=-=-=-=-=-=-=-=-' PRINT *, '!! WORK IN PROGRESS !!' PRINT *, '=-=-=-=-=-=-=-=-=-=-=-=' CALL display(balance) PRINT *, 'how much would you like to bet?' READ (*,*) currentBet PRINT *, '--------------------------------------' WRITE(*, '(A,I0)') 'dealers hand: ', randomCard1, '???' WRITE(*, '(A,I0)') 'your hand: ', randomCard2, randomCard3 PRINT *, 'enter "HIT" or "STAND"' READ (*,*) blackjackHorS IF(blackjackHorS == "H") THEN PRINT *, 'hit... AND ITS OUT OF THE PARK' END IF IF(blackjackHorS == "S") THEN PRINT *, 'standing... loser' END IF end subroutine !------------------------------------------------------------------- subroutine findArea(selectedAreaFind) IMPLICIT NONE REAL :: selectedAreaFind, a, b, h, r, s, foundArea IF(selectedAreaFind == 1) THEN PRINT *, 'enter your side (s)' READ (*,*) s foundArea = s*s PRINT *, ' ', s PRINT *, '----------' PRINT *, '| |' PRINT *, '| |', s PRINT *, '| |' PRINT *, '----------' WRITE(*, '(A,G0)') 'the area of your square is,', foundArea ELSE IF(selectedAreaFind == 2) THEN PRINT *, 'enter your base (b)' READ (*,*) b PRINT *, 'enter your height (h)' READ (*,*) h foundArea = b*h PRINT *, ' ', b PRINT *, '---------------' PRINT *, '| |' PRINT *, '| |', h PRINT *, '| |' PRINT *, '---------------' WRITE(*, '(A,G0)') 'the area of your rectangle is,', foundArea ELSE IF(selectedAreaFind == 3) THEN PRINT *, 'enter your radius (r)' READ (*,*) r foundArea = 3.14159*((r)**2) PRINT *, " ---" PRINT *, " / \" PRINT *, "( *--)" PRINT *, " \ /" PRINT *, " ---" WRITE(*, '(A,G0)') 'the area of your circle is,', foundArea ELSE IF(selectedAreaFind == 4) THEN PRINT *, 'enter your base (b)' READ (*,*) b PRINT *, 'enter your height (h)' READ (*,*) h foundArea = ((b*h)/2) PRINT *, ' ', b PRINT *, ' ^' PRINT *, ' / \' PRINT *, ' / \', h PRINT *, '/ \' PRINT *, '---------' WRITE(*, '(A,G0)') 'the area of your triangle is,', foundArea ELSE IF(selectedAreaFind == 5) THEN PRINT *, 'enter your base (b)' READ (*,*) b PRINT *, 'enter your height (h)' READ (*,*) h foundArea = b*h PRINT *, ' ',b PRINT *, ' ----------' PRINT *, ' / /' PRINT *, ' / /', h PRINT *, '/ /' PRINT *, '---------' WRITE(*, '(A,G0)') 'the area of your parallelogram is,', foundArea ELSE IF(selectedAreaFind == 6) THEN PRINT *, 'enter your base 1 (b)' READ (*,*) b PRINT *, 'enter your base 2 (a)' READ (*,*) a PRINT *, 'enter your height (h)' READ (*,*) h foundArea = (((a+b)*h)/2) PRINT *, ' ', b PRINT *, ' -----' PRINT *, ' / \' PRINT *, ' / \', h PRINT *, '/ \' PRINT *, '--------------' PRINT *, ' ', a WRITE(*, '(A,G0)') 'the area of your trapezoid is,', foundArea ELSE IF(selectedAreaFind == 7) THEN PRINT *, 'enter your a axis (a)' READ (*,*) a PRINT *, 'enter your b axis (b)' READ (*,*) b foundArea = 3.14159*a*b PRINT *, " -------" PRINT *, " / \" PRINT *, "( *----)" PRINT *, " \ | /" PRINT *, " -------" WRITE(*, '(A,G0)') 'the area of your ellipse is,', foundArea ELSE CALL EXIT(999) END IF end subroutine !other ideas !roman numeral converter !morse code / base64 encoder/decoder !---------------graveyard--------------- !------ prime number failed------ !extraInt = 1 !DO n = 1, 200 !IF(extraInt / (extraInt-1) /= 1) THEN !PRINT *, 'not prime, skipping' !PRINT *, extraInt !END IF !IF(extraInt / (extraInt-1) == extraInt) THEN !PRINT *, extraInt !END IF !IF(extraInt / (extraInt-1) == 1) THEN !PRINT *, extraInt !END IF !extraInt = extraInt + 1 !END DO !-------------older temp converts--------------- !PRINT *, 'are you converting from F or C?' !PRINT *, '1 - from F to C' !PRINT *, '2 - from C to F' !PRINT *, '3 - from F to K' !PRINT *, '4 - from C to K' !PRINT *, '5 - from K to F' !PRINT *, '6 - from K to C' !READ (*,*) selectedTempConvert !IF(selectedTempConvert == 1) THEN ! FROM F TO C !PRINT *, "enter your temperature in F" !READ (*,*) enteredF !finalC = (enteredF - 32) * 5/9 !PRINT *, enteredF, "F in C is: ", finalC !ELSE IF(selectedTempConvert == 2) THEN ! FROM C TO F !PRINT *, "enter your temperature in C" !READ (*,*) enteredC !finalF = (1.8 * enteredC) + 32 !PRINT *, enteredC, "C in F is: ", finalF !END IF !------------------------------------------------------------------------- !PRINT *, 'your first input will be converted to your second input' !PRINT *, 'enter the temperature you want to convert' !READ (*,*) temp1 !PRINT *, 'enter the unit for that temperature (C, F, K)' !READ (*,*) temp1unit !PRINT *, 'enter the unit you want to convert into (C, F, K)' !READ (*,*) temp2unit !conversions below ------------------------- !IF(temp1unit == "C") THEN !IF(temp2unit == "F") THEN !temp2 = (temp1 * 9/5) + 32 !converting c to f !ELSE IF(temp2unit == "K") THEN !temp2 = temp1 + 273.15 !converting c to k !END IF !END IF !IF(temp1unit == "F") THEN !IF(temp2unit == "C") THEN !temp2 = (temp1 - 32) * 5/9 !converting f to c !ELSE IF(temp2unit == "K") THEN !temp2 = (temp1 - 32) * 5/9 + 273.15 !converting f to k !END IF !END IF !IF(temp1unit == "K") THEN !IF(temp2unit == "F") THEN !temp2 = (temp1 - 273.15) * 9/5 + 32 !converting from k to f !ELSE IF(temp2unit == "C") THEN !temp2 = temp1 - 273.15 !converting k to c !END IF !END IF !conversions above ------------------------- !PRINT *, " " !WRITE(*, '(A,A,A,A,A,I0)') temp1, temp1unit, ' in ', temp2unit, ' is ', temp2

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue