Lab 1

Description:
The function of the following program is to convert decimal numbers to roman numbers.
The program asks the user to enter a decimal number and then it will convert the number. In order to create we were ask to use If then, while, elseif, then, sub (eax,number) as functions. So the program can perform its conversion.

Code:

program lab1;
#include("stdlib.hhf")

static
	numero: int32:=1;
 begin lab1;
        while(numero != 0) do
	stdout.put("** The Following Program Will Covert Your Decimal Number into a Roman Numeral **",nl);
	stdout.put("Please Enter Your Decimal Number: ");
	stdin.get(numero);
	mov(numero,eax);
	
	if(eax0) then
		 stdout.put("Your Number Decimal Number is: ",numero,"",nl);
		 stdout.put("Your Roman Numeral is: ");
		 
	if(eax>=1000 && eax=1000) do
			sub(1000, eax);
				stdout.put("M");
					endwhile;
						endif;				
	if(eax>=900) then
		sub(900, eax);
		    stdout.put("CM");
				endif;
	if(eax>=500) then
		sub(500, eax);
			stdout.put("D");
				endif;
	
	if(eax>=400) then 
		sub(400,eax);
			stdout.put("CD");
				endif;
				
	if(eax>=100 && eax=100) do
			sub(100, eax);
				stdout.put("C");
					endwhile;
						endif;
						
	if(eax>=90) then
		sub(90, eax);
			stdout.put("XC");
				endif;
				
	if(eax>=50) then
		sub(50, eax);
			stdout.put("L");
				endif;
	
	if(eax>=40) then 
		sub(40,eax);
			stdout.put("XL");
				endif;
	
	if(eax>=10 && eax=10) do
			sub(10, eax);
				stdout.put("X");
					endwhile;
						endif;
						
	if(eax>=9) then
		sub(9, eax);
			stdout.put("IX");
				endif;
				
	if(eax>=5) then
		sub(5, eax);
			stdout.put("V");
				endif;
	if(eax>=4) then 
		sub(4,eax);
			stdout.put("IV");
				endif;
	if(eax>=1 && eax=1) do
			sub(1, eax);
				stdout.put("I");
					endwhile;
						endif;
						
	stdout.put("",nl,nl);
		endif;
			endwhile;
end lab1;

 

Screenshot:

lab 1

Leave a Reply

Your email address will not be published. Required fields are marked *