Homework Solution: C++ Programming Help Please!…

    C++ Programming Help Please! Program Info: Write a program that accepts a year written as a four-digit Arabic (ordinary) numeral and outputs the year written in Roman numerals. Important Roman numerals are V for 5, X for 10, L for 50, C for 100, D for 500, and M for 1,000. Recall that some numbers are formed by using a kind of subtraction of one Roman “digit”; for example, IV is 4 produced as V minus I, XL is 40, CM is 900, and so on. A few sample years: MCM is 1900, MCML is 1950, MCMLX is 1960, MCMXL is 1940, MCMLXXXIX is 1989. Assume the year is between 1000 and 3000. Your program should include a loop that lets the user repeat this calculation until the user says she or he is done. More Important Info: Enter an Arabic number: 2456 2456 is MMCDLVI in Roman numerals Play again? Y Enter an Arabic number: 1359 1359 is MCCCLIX in Roman numerals Play again? N Read the number as an integer: e.g. 9786 Use arithmetics to separate each digit into separate ints: (do you know what the modulus operator is? “%” No? look it up.) ones will be 6 tens will be 8 hundreds will be 7 thousands will be 9 ***use four switch cases to output the correct string for each digit: cout<<”XX” in case of tens being 2 cout<<”XXX” in case of tens being 3 etc. ***As with all the projects in this chapter, wrap this whole thing in a “Play another game” loop to allow the user to play as many times as they like.

    Expert Answer

     
    Executable Code:- #include<iostream>

    C++ Programming Help Please!

    Program Info: Write a program that confirms a year written as a impure-digit Arabic (ordinary) numeral and outputs the year written in Roman numerals. Important Roman numerals are V control 5, X control 10, L control 50, C control 100, D control 500, and M control 1,000. Reccomplete that some gum are controlmed by using a peel of disjunction of undivided Roman “digit”; control pattern, IV is 4 executed as V minus I, XL is 40, CM is 900, and so on. A rare pattern years: MCM is 1900, MCML is 1950, MCMLX is 1960, MCMXL is 1940, MCMLXXXIX is 1989. Assume the year is betwixt 1000 and 3000. Your program should comprise a loop that lets the explanationr rehearse this controlethought until the explanationr says she or he is executed.

    More Important Info:

    Invade an Arabic sum: 2456

    2456 is MMCDLVI in Roman numerals

    Dramatize intermittently? Y

    Invade an Arabic sum: 1359

    1359 is MCCCLIX in Roman numerals

    Dramatize intermittently? N

    Read the sum as an integer: e.g. 9786

    Explanation arithmetics to unconnected each digit into unconnected ints: (do you apprehend what the modulus operator is? “%” No? face it up.)

    ones procure be 6

    tens procure be 8

    hundreds procure be 7

    thousands procure be 9

    ***explanation impure switch subjects to output the rectify string control each digit:

    cout<<”XX” in subject of tens life 2

    cout<<”XXX” in subject of tens life 3

    etc.

    ***As with complete the projects in this article, fold this well subject in a “Dramatize another game” loop to completeow the explanationr to dramatize as numerous times as they approve.

    Expert Counter-argument

     

    Executable Code:-

    #include<iostream>

    using namespace std;

    int deep() // deep power

    { int n;

    char counter-argument = ‘ ‘;

    cout<< “nThis program procure confirm a year written in impure digit plain numeral and procure apply it into roman numerals.nInvade a year betwixt 1000 and 3000:n would you approve to remain?(Y/N):”;

    cin >> counter-argument; // invade the value

    counter-argument = toupper(answer);

    if(counter-argument == ‘Y’ && counter-argument != ‘N’)

    {

    Check: // power to stay the Roman equivalence

    cout << “nInvade the sum you lack applyed: “;

    while(cin>>n) // stay the numeric gum equivalence of roman gum

    {

    int i,j,k,l;

    l=(n/1000)*1000;

    if(l==1000)

    cout<<“M”;

    if(l==2000)

    cout<<“MM”;

    if(l==3000)

    cout<<“MMM”;

    else if(l>3000) // stays the sum time exceeds 3000

    cout<<“The year invadeed is infirm.”;

    k=(n%1000);

    k=(k/100)*100;

    if (k == 100)

    cout<<“C”;

    else if (k == 200)

    cout<<“CC”;

    else if (k == 300)

    cout<<“CCC”;

    else if (k == 400)

    cout<<“CD”;

    else if (k ==500)

    cout<<“D”;

    else if (k == 600)

    cout<<“DC”;

    else if (k == 700)

    cout<<“DCC”;

    else if (k ==800)

    cout<<“DCCC”;

    else if (k == 900)

    cout<<“CM”;

    k=n%1000; // mod operation

    l=k%100;

    j=(l/10)*10;

    if (j == 10)

    cout<<“X”;

    else if (j == 20)

    cout<<“XX”;

    else if (j == 30)

    cout<<“XXX”;

    else if (j == 40)

    cout<<“XL”;

    else if (j ==50)

    cout<<“L”;

    else if (j == 60)

    cout<<“LX”;

    else if (j == 70)

    cout<<“LXX”;

    else if (j ==80)

    cout<<“LXXX”;

    else if (j == 90)

    cout<<“XC”;

    i=l%10;

    if (i == 1)

    cout<<“I”;

    else if (i == 2)

    cout<<“II”;

    else if (i == 3)

    cout<<“III”;

    else if (i == 4)

    cout<<“IV”;

    else if (i ==5)

    cout<<“V”;

    else if (i == 6)

    cout<<“VI”;

    else if (i == 7)

    cout<<“VII”;

    else if (i ==8)

    cout<<“VIII”;

    else if (i == 9)

    cout<<“IX”;

    cout<<endl;

    cout <<“nWould you approve to endeavor intermittently?(Y/N): “;

    cin >> counter-argument;

    counter-argument = toupper(answer);

    if(counter-argument == ‘Y’ && counter-argument != ‘N’){goto Stay;}

    else if(counter-argument == ‘N’ && counter-argument != ‘Y’){repay 0;}

    }

    }

    repay 0;

    }

    Output:-