1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
joja [24]
3 years ago
10

Write a program roman which converts numbers from decimal notation into Roman numerals. roman takes a single argument, a string

containing a non-negative integer, and prints its Roman numeral equivalent to standard output. g
Computers and Technology
1 answer:
MaRussiya [10]3 years ago
3 0

Answer:

// Program is written in C++ programming language

/ Comments are used for explanatory purpose

// Program starts here

#include<bits/stdc++.h>

using namespace std;

//Declare a function named value to represent the symbols of Roman Numerals

int value(char xy)

{

if (xy == 'I') { return 1; }

if (xy == 'V') { return 5; }

if (xy == 'X') { return 10; }

if (xy == 'L') { return 50; }

if (xy == 'C') { return 100; }

if (xy == 'D') { return 500; }

if (xy == 'M') { return 1000; }

return -1;

}

// Convert to numbers , taking Variable named input as input

int Converted(string &input)

{

// Declare a variable to store the calculated output

int calc;

// Set to 0

calc = 0;

// Iterate through input from 0 to the last character

for (int i=0; i<input.length(); i++)

{

int check1 = value(input[i]);

if (i+1 < input.length())

{

int check12= value(input[i+1]);

// Comparing both values

if (check1>= check2)

{

calc+ =check1;

}

else

{

calc+ =check2 - check1;

i++;

}

}

else

{

calc+ =check1;

}

}

return calc;

}

// Main method starts here

int main()

{

// String input declaration

string inp;

cout<"Enter any valid Roman numeral";

cout << "Result is "

<< Converted(inp);

return 0;

}

You might be interested in
What would you have to know about the pivot columns in an augmented matrix in order to know that the linear system is consistent
Scrat [10]

Answer:

The Rouché-Capelli Theorem. This theorem establishes a connection between how a linear system behaves and the ranks of its coefficient matrix (A) and its counterpart the augmented matrix.

rank(A)=rank\left ( \left [ A|B \right ] \right )\:and\:n=rank(A)

Then satisfying this theorem the system is consistent and has one single solution.

Explanation:

1) To answer that, you should have to know The Rouché-Capelli Theorem. This theorem establishes a connection between how a linear system behaves and the ranks of its coefficient matrix (A) and its counterpart the augmented matrix.

rank(A)=rank\left ( \left [ A|B \right ] \right )\:and\:n=rank(A)

rank(A)

Then the system is consistent and has a unique solution.

<em>E.g.</em>

\left\{\begin{matrix}x-3y-2z=6 \\ 2x-4y-3z=8 \\ -3x+6y+8z=-5  \end{matrix}\right.

2) Writing it as Linear system

A=\begin{pmatrix}1 & -3 &-2 \\  2& -4 &-3 \\ -3 &6  &8 \end{pmatrix} B=\begin{pmatrix}6\\ 8\\ 5\end{pmatrix}

rank(A) =\left(\begin{matrix}7 & 0 & 0 \\0 & 7 & 0 \\0 & 0 & 7\end{matrix}\right)=3

3) The Rank (A) is 3 found through Gauss elimination

(A|B)=\begin{pmatrix}1 & -3 &-2  &6 \\  2& -4 &-3  &8 \\  -3&6  &8  &-5 \end{pmatrix}

rank(A|B)=\left(\begin{matrix}1 & -3 & -2 \\0 & 2 & 1 \\0 & 0 & \frac{7}{2}\end{matrix}\right)=3

4) The rank of (A|B) is also equal to 3, found through Gauss elimination:

So this linear system is consistent and has a unique solution.

8 0
2 years ago
Write a function call it isEvenPositiveInt which takes an integer x and return true if x is positive and also even. Note isinsta
Anna11 [10]

Answer:

The program to this question as follows:

Program:

def isEvenPositiveInt(x): #defining method isEvenPositiveInt

   if x>0: #checking number is positive or not

       if x%2==0: #check true condition

           return True #return value True

       else:

           return False #return value False

   return False #return value False

print(isEvenPositiveInt(24)) #calling method and print return value

print(isEvenPositiveInt(-24)) #calling method and print return value

print(isEvenPositiveInt(23)) #calling method and print return value

Output:

True

False

False

Explanation:

In the above Python program, a method "isEvenPositiveInt" is defined, that accepts a variable "x" as its parameter, inside the method a conditional statement is used, which can be described as follows:

  • In the if block the condition "x>0" is passed, that check value is positive, if this condition is true, it will go to another if block.
  • In another, if block is defined, that checks the inserted value is even or not, if the value is even it will return "true", otherwise it will go to the else part, that returns "false".  
5 0
3 years ago
Game Informer (often abbreviated to GI) is an American-based monthly magazine featuring articles, news, strategy, and reviews of
Eddi Din [679]

Answer:

it is d i just took it

Explanation:

6 0
3 years ago
Read 2 more answers
An online game is played with two dice. In this context, explain what is meant by decomposition.
Vlad [161]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

This question is about desinging a game that is played with two dice and gets or shows their value to the player.

The dice value is random, and it can be between one and six. So, you need to generate two numbers between 1 and 6. You may also need to display the numbers

The main part of this program is that you need to know the numbers to limit or restrict what the user may do next while playing.

That's most of the first level of decomposition for solving a problem. In decomposition, you need to keep decomposing (breaking) the problem into smaller pieces, thinking outline of the program and deciding what objects, functions, variables, and logic you're going to implement in the coding.

4 0
3 years ago
Explain the following terms:<br><br> a) Atomicity<br><br> b) DML
GenaCL600 [577]

Answer:

a) Atomicity:- It is among the one of the ACID properties of transactions.It states that an atomic transaction is irreducible and indivisible series of data operations such that either nothing occurs or all occurs.

b) DML(Data Manipulation Language):- It is a computer programming language that is used for inserting,deleting,manipulating data in the database.For example -SQL.

6 0
3 years ago
Other questions:
  • When using the wait and signal operations, ____ sets the process's process control block to the blocked state and links it to th
    12·1 answer
  • Given input characters for an arrowhead and arrow body, print a right-facing arrow. Ex: If the input is: *
    14·1 answer
  • A word that has a specific, predefined meaning in a programming language is called
    8·1 answer
  • Need help with just #8
    12·1 answer
  • Your unit has an upcoming training event. What form is used to record and maintain document numbers for ammunition documents?
    5·1 answer
  • Using the phase plane program, plot the phase plane for the Lotka-Volterra model:
    11·1 answer
  • If your TV was showing a flat black or blue screen, or had "snow", what steps would you take to fix it?
    13·1 answer
  • Ling has configured a delegate for her calendar and would like to ensure that the delegate is aware of their permissions. Which
    13·2 answers
  • Which version of java should i use?.
    13·1 answer
  • Type the correct answer in the box. Spell all words correctly. Kenny is designing a document for the employee motivation campaig
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!