Created
December 18, 2011 11:55
-
-
Save ToJans/1493152 to your computer and use it in GitHub Desktop.
Essay code samples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; com files are always loaded at 100h address | |
ORG 100h | |
start: ; make sure data segments and extra segments point | |
; to the same segment as the code, since this is a | |
; com app | |
MOV AX,CS | |
MOV DS,AX | |
MOV ES,AX | |
JMP readkey | |
invalidkey: ; print error message | |
MOV AH,9 | |
MOV DX, errormessage | |
INT 21h | |
readkey: ; print inputmessage | |
MOV AH,9 | |
MOV DX, inputmessage | |
INT 21h | |
; read key from keyboard, result is stored in AL | |
MOV AH,1 | |
INT 21h | |
; if it is smaller then 'a' go to invalidkey label | |
CMP AL,'a' | |
JL invalidkey | |
; if it is larger then 'z' go to invalidkey label | |
CMP AL,'z' | |
JG invalidkey | |
; set lowerval in the output sting | |
MOV [lowerval],AL | |
; make AL uppercase | |
ADD AL,'A'-'a' | |
; set upperval in the output sting | |
MOV [upperval],AL | |
; print outputmessage | |
MOV AH,9 | |
MOV DX, outputmessage | |
INT 21h | |
; Terminate app | |
INT 20h | |
inputmessage db 0Dh,0Ah,"Please enter a lowercase letter (a-z): $" | |
errormessage db 0Dh,0Ah,"Invalid input: this is not a lowercase letter!$" | |
outputmessage db 0Dh,0ah,"The uppercase of " | |
lowerval db 0 | |
db " is " | |
upperval db 0,0Dh,0Ah,"$" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Program Essay; | |
uses SysUtils,Crt; | |
function ReadLowercaseLetter():char; | |
begin | |
while true do | |
begin | |
writeln('Please enter a lowercase letter (a-z):'); | |
ReadLowercaseLetter := ReadKey; | |
if (ReadLowercaseLetter in ['a'..'z']) then | |
exit | |
else | |
writeln('Invalid input: this is not a lowercase letter!'); | |
end; | |
end; | |
var | |
letter:char; | |
begin | |
letter := ReadLowercaseLetter(); | |
writeln('The uppercase of '+letter+' is '+UpperCase(letter)); | |
end. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Essay | |
{ | |
public class EssayConsole | |
{ | |
char letter; | |
public void ReadLowercaseLetter() | |
{ | |
while (true) | |
{ | |
Console.WriteLine("Please enter a lowercase letter (a-z):"); | |
var key = Console.ReadKey().KeyChar; | |
if (key >= 'a' && key <= 'z') | |
return; | |
else | |
Console.WriteLine("Invalid input: this is not a lowercase letter!"); | |
} | |
} | |
public void WriteLastReadLetterAsUppercase() | |
{ | |
Console.WriteLine("The uppercase of {0} is {1}",letter,letter+'A'-'a'); | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var console = new EssayConsole(); | |
console.ReadLowercaseLetter(); | |
console.WriteLastReadLetterAsUppercase(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#light | |
open System | |
let ucase x = x.ToString().ToUpper() | |
let islowercase x = x >= 'a' && x <= 'z' | |
let rec getlcasechar _ = | |
printfn "Please enter a lowercase letter (a-z):" | |
let letter = (Console.ReadKey().KeyChar); | |
printfn"" | |
if islowercase(letter) then | |
letter | |
else | |
printfn("Invalid input: this is not a lowercase letter!") | |
getlcasechar() | |
let lcasechar = getlcasechar() | |
printf "The uppercase of %c is %s" lcasechar (ucase lcasechar) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#light | |
open System | |
let ucase x = x.ToString().ToUpper() | |
let islowercase x = x >= 'a' && x <= 'z' | |
let rec getlcasechar _ = | |
printfn "Please enter a lowercase letter (a-z):" | |
let letter = (Console.ReadKey().KeyChar); | |
printfn"" | |
if islowercase(letter) then | |
letter | |
else | |
printfn("Invalid input: this is not a lowercase letter!") | |
getlcasechar() | |
let lcasechar = getlcasechar() | |
printf "The uppercase of %c is %s" lcasechar (ucase lcasechar) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This article provides a helpful review of the top services for students looking to buy lab reports online . It’s well-organized, breaking down quality, pricing, and reliability, which is crucial when choosing a service. I appreciated the focus on comparing the strengths and weaknesses of each platform, making it easier to pick the right one for specific needs. As a student, time constraints can make these services appealing, but it’s important to use them ethically. Overall, this is a valuable resource for understanding the options available while navigating academic challenges.