Question

C++ to Pep/8 assembly language

Translate the following C++ program to Pep/8 assembly language.  Convert the given number into its roman numeral equivalent.


class solution:


   def int_to_Roman(self, num):

       value = [
           1000, 900, 500, 400,
           100, 90, 50, 40,
           10, 9, 5, 4,
           1

           ]

       symbol = [
           "M", "CM", "D", "CD",
           "C", "XC", "L", "XL",
           "X", "IX", "V", "IV",
           "I"

           ]

       roman_num = ''

       i = 0


       while  num > 0:
           for _ in range(num // value[i]):
               roman_num += symbol[i]
               num -= value[i]
           i += 1

       return roman_num

print(solution().int_to_Roman(1))

print(solution().int_to_Roman(4000))


Any help is appreciated. Thank you!
0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 9 more requests to produce the answer.

1 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
C++ to Pep/8 assembly language
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Convert C++ language to PEP/8 assembly language

    Convert this C++ language to PEP/8 assembly language. #include <stdio.h> int main(void) {        int num, rem;     printf("Enter a number: ");     scanf("%d", &num);     printf("Roman numerals: ");             while(num != 0)     {         if (num >= 1000)       // 1000 - m         {            printf("m");            num -= 1000;         }         else if (num >= 900)   // 900 -  cm         {            printf("cm");            num -= 900;         }                 else if (num >= 500)   // 500 - d         {                       printf("d");            num -= 500;         }         else if (num >= 400)   // 400 -  cd         {            printf("cd");            num -= 400;         }         else if (num >= 100)   // 100 - c         {            printf("c");            num -= 100;                                }         else if (num >= 90)    // 90 - xc         {            printf("xc");            num -= 90;                                                       }         else if (num >= 50)    // 50 - l         {            printf("l");            num -= 50;                                                                              }         else if (num >= 40)    // 40 - xl         {            printf("xl");                       num -= 40;         }         else if (num >= 10)    // 10 - x         {            printf("x");            num -= 10;                    }         else if (num >= 9)     // 9 - ix         {            printf("ix");            num -= 9;                                  }         else if (num >= 5)     // 5 - v         {            printf("v");            num -= 5;                                              }         else if (num >= 4)     // 4 - iv         {            printf("iv");            num -= 4;                                                                     }         else if (num >= 1)     // 1 - i         {            printf("i");            num -= 1;                                                                                            }     }     return 0;}

  • PEP/8 Assembly language

    Convert the given integer number into its roman numeral equivalent between 1 and 3999. In PEP/8 assembly language.

  • Translate the following C program to Pep/9 assembly language. #include <stdio.h> int main() {     int...

    Translate the following C program to Pep/9 assembly language. #include <stdio.h> int main() {     int number;     scanf("%d", &number);     if (number % 2 == 0) {         printf("Even\n");     }     else {         printf("Odd\n");     }     return 0; }

  • Translate the following C program to Pep/9 assembly language. #include <stdio.h> const int limit = 5;...

    Translate the following C program to Pep/9 assembly language. #include <stdio.h> const int limit = 5; int main() { int number; scanf("%d",&number); while (number < limit){ number++; printf("%d",number); } return 0; }

  • This is a PHP code. It is a project of roman converter Can someone explain this...

    This is a PHP code. It is a project of roman converter Can someone explain this statement to me? What does it mean? $romanValid = "/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/"; and in the second function, what does the first&neighbor stand for? can you explain the logic of this function for me, please?? thank you function validRoman($str) $romanValid = "/"M{0,4}(CM CD D2C{0,37) (XC XL L?X{0,33) (IX IVV?10,3)/": return (preg_match($romanValid, $str)); function RomanToNum($str) $first = 0; $neighbor = 0; $result = 0; $len = strlen($str); for...

  • Can someone code this asap? Use any language that you want. 2. Ancestral Names Given a...

    Can someone code this asap? Use any language that you want. 2. Ancestral Names Given a list of strings comprised of a name and a Roman numeral, sort the list first by name, then by decimal value of the Roman numeral. In Roman numerals, a value is not repeated more than three times. At that point, a smaller value precedes a larger value to indicate subtraction. For example, the letter I represents the number 1, and Vrepresents 5. Reason through...

  • Write a Java program. In the "modern Roman" system a number is also a sequence of...

    Write a Java program. In the "modern Roman" system a number is also a sequence of M's, D's, C's, L's, X's, V's, and 1's. The symbols have to appear more or less in that order and the value of a number is obtained as before with one important exception: A symbol C, X, or I may precede a symbol of higher value, in which case the value of that symbol C, X, or I is taken to be negative. Write...

  • Translate the following C program to Pep/9 assembly language. It multiplies two integers using a ...

    Translate the following C program to Pep/9 assembly language. It multiplies two integers using a recursive shift-and-add algorithm. mpr stands for multiplier and mcand stands for multiplicand. A recursive integer multiplication algorithm #include <stdio.h> int times(int mpr, int mcand) {    if (mpr == 0) {       return 0;    }    else if (mpr % 2 == 1) {       return times(mpr / 2, mcand * 2) + mcand;    }    else {       return times(mpr / 2, mcand * 2);    } } int main() {    ...

  • Write up a detailed solution to the problem: Design a program to convert a Roman numeral...

    Write up a detailed solution to the problem: Design a program to convert a Roman numeral to a decimal number. The program should read a Roman numeral. You may read it as a string or one character at a time. Do the conversion and then output the decimal number. Here are the “letters” you need to know: Symbol =   Value I   = 1 V =   5 X =   10 L =   50 C =   100 D =   500 M   =...

  • (c++) Write a program that converts a positive integer into the Roman number system.(c++) Roman numbers....

    (c++) Write a program that converts a positive integer into the Roman number system.(c++) Roman numbers. Write a program that converts a positive integer into the Roman number system. The Roman number system has digits I 1 V 5 X 10 L 50 C 100 D 500 M 1,000 Numbers are formed according to the following rules. (1) Only numbers up to 3,999 are represented. (2) As in the decimal system, the thousands, hundreds, tens, and ones are expressed separately....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT