C++ :: Calculator To Gives Result Of Roman Numerals In Roman Mode

Dec 5, 2013

About exercise 7 of chapter 10 of PPP (page 372): changing the calculator to gives us the result of the roman numerals, like XXI + CIV = CXXV.

At *first* time there are two solutions for solving it in my mind.

First is, giving each roman number to a function like the one existing in exercise 6 and then get their integer numbers and then calculate them by the calculator of chapter 7 and finally make a function to convert the result to roman mode. (simpler)

Second is to change the calculator from chapter 7 to calculate roman numbers inside itself and gives the result again in roman mode. (harder)

As an important step of ‘solving the problems’/’programming’, how can I make decision to choose a solution for solving a problem.

View 8 Replies


ADVERTISEMENT

C++ :: Turning Arabic Numerals To Roman Numerals?

Nov 11, 2013

this program is supposed to turn Arabic Numbers into Roman Numerals, but after making the program shown below I only am able to get some alt codes to show up (I got a green lantern symbol to show up)

How would I fix this program to show Roman numerals?

#include <iostream>
#include <climits>
#include <cctype>
using namespace std;
int main(void)//makes all values void until entered {
system("color 0C");
while(true)

[code]....

View 1 Replies View Related

C :: Convert Integers To Roman Numerals?

Nov 19, 2014

how to convert integers -> Roman Numerals using both if & switch statement.

View 3 Replies View Related

C++ :: Converting Date To Roman Numerals

Feb 26, 2014

Program to convert a date entered into roman numerals. I can only use one output prompt to get the date, so that makes it more difficult. Here is what i have, but how to go about the rest of it.

#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int array_date[20];
char I; // one

[Code] .....

View 1 Replies View Related

C/C++ :: Convert Integers To Roman Numerals

Mar 23, 2015

I've Been working on a program that acts as a form of Roman numeral calculator, I input Roman Numeral Characters, and the program (is suppose to) output the corresponding digits. *Not allowed to use for loops or arrays.

Input:
MCCXXVI
LXVIIII
+

Output:
The First number is 1226
The second number is 69
Arithmetic operation is +
the sum of 1226 and 69 is MCCLXXXXV (1295)

However, when I run the program:

input:
MCCXXVI
LXVIIII
+

Output:
The first number is 77
The second number is 76
Arithmetic Operation is +
The sum of 77 and 76 is (infinite loop of I's) (153)

I noticed that when I input MCCXXVI, it only takes the first character (I thought cin.get() was suppose to stop this?), and returns the ASCII decimal value of that, instead of the integer value that I assigned to each letter. Why i get an infinite loop, and how to fix it.

#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
const int I_Value = 1;
const int V_Value = 5;

[Code] ....

View 14 Replies View Related

C :: Convert Roman Numerals Into Decimal Numbers

Oct 11, 2013

So I am trying to write a program that converts roman numerals into decimal numbers. I so far have come up with:

Code:
#include <stdio.h>
#include <ctype.h> // importing the tolowerfunction
//variables
int decimal, total;
char numeral[];

[Code] .....

But each time I compile it, it times out as if it were hitting an infinite loop. I have a feeling that I am not passing an individual character to the roman_to_decimal function but am unsure why.

View 5 Replies View Related

C++ :: Roman Num To Int Program

Dec 20, 2013

Basically i am really close (i think) and the numbers im getting when i run it are weird like for instance i should get back a one if i enter in I or i but instead im getting like 178976087.

MAIN:

#include "stdafx.h"
#include "iostream"
#include <iomanip>
#include "romanType.h"

using namespace std;
int main() {
romanType r;

[Code] .....

View 5 Replies View Related

C/C++ :: Roman Numeral Converter?

Dec 23, 2013

I am writing a program that converts arabic numbers into roman numerals.

Quote Write a program that asks the user to enter a number within the range of 1 through 10. Use a switch statement to display the Roman numeral version of that number.

Input Validation: Do not accept a number less than 1 or greater than 10.

Prompts And Output Labels. Use the following prompt for input: "Enter a number (1 - 10): ". The output of the program should be of the form "The Roman numeral version of A is R" where A is the Arabic numeral entered (1,2,3,...) and R is the all-capitals form of a Roman numeral, such as VII.

View 14 Replies View Related

C++ :: Roman Numeral Project Using Classes

Aug 31, 2014

Here is the problem:"Write a program that converts a number entered in Roman numerals to a positive integer. Your program should consist of a class, say, romanType. An object of type romanType should do the following:

a. Store the number as a positive integer.
b. Convert and store the number as a positive integer.
c. Print the number as a Roman numeral or positive integer as requested by the user.

The integer values of the Roman numerals are:

M 1000
D 500
C 100
L 50
X 10
V 5
I 1

d. Test your program using the following Roman numerals: MCXIV, CCCLIX, MDCLXVI."I'm doing the best I can to understand the concept of the class. Here is what I have (which is not much thus far, and nowhere near correct I'm sure).

#include<iostream>
#include<iomanip>
using namespace std;
class romanType {
public:
void getRoman();

[code]....

View 19 Replies View Related

C/C++ :: Convert Decimal Number To Roman?

Sep 17, 2014

#include "stdio.h"
#include <stdarg.h>
#include <math.h>
// Main Function
int main(void){
int number;
printf(" Please enter a number from 1-10? ");
scanf("%d", &number);

[Code] ....

I took the while statement out didn't want that in there.

View 2 Replies View Related

C :: Convert Roman Numeral Inputs To Normal Numbers?

May 4, 2014

I have a fascination with Roman numerals and would like to create a C program that converts Roman numeral inputs to normal numbers.

I want to keep everything simple and only use the C library for the coding.

View 4 Replies View Related

Visual C++ :: Roman Numeral Converter To Decimal Using Array Of Strings

Jun 27, 2013

This program compiles, but has a bunch of logical errors. I know my problem is somewhere in the while loop that I have, but I can't figure out where. Here are some of the issues I am experiencing:

1. At the beginning of the program it asks you to enter a number, and when you do it does nothing while proceeding to the while loop where I have it asking the same question

Code:
"Please enter a number between 1 and 20 (Enter 0 to stop)
";
cin >> num;
cout << endl;

I want to be able to eliminate that first statement but if I only run this in the loop without the above statement the program will display nothing on the screen and proceeds to stop.

2. This code runs fine, except that if you make a mistake, it will prompt you to enter a valid number, however; it ignores your first response if the number you enter is valid and asks you to enter a valid number anyway. Once you enter it a second time, it will accept it and the program will continue on.

Code:
while(num != SENTINEL) {
cout << "Please enter a number between 1 and 20 (Enter 0 to stop) ";
cin >> num;
cout << endl;

Also if you type in 0 on your first response, it will prompt you that it is not a valid number and ask you to try again, instead of stopping the program like it is supposed to do. On your second response the program will accept your 0 and stop the program correctly.

//Write a program that displays the roman numeral equivalent of any decimal number between 1 and 20 that the user enters. The roman numerals should be stored in an array of strings and the decimal number that the user enters should be used to locate the array element holding the roman numeral equivalent. The program should have a loop that allows the user to continue entering numbers until an end sentinel of 0 is entered.

Input validation: Do not accept scores less than 0 or greater than 20

#include <iostream>
#include <string>
using namespace std;
int main() {
// Declare constants and variables
const int romanNum = 21; // Size of the elements in the array

[Code] ....

View 14 Replies View Related

C++ :: Simple Calculator - Result Will Always Equal Zero

Jan 21, 2014

I'm making a simple calculator and have done it all right where you can input everything, all the functions are there, but when i run the program it will come to displaying the result and it will always equal zero, I just need it to say 8+8 = 16 rather than 8+8 = 0, i don't know whether its just displaying the results as 0, or not displaying it at all, the code will follow below:

Code:

#include<iostream>
using namespace std;
double num3;
double num2;
double result;
char operation;

[Code] ....

View 4 Replies View Related

C :: Calculator Doesn't Compile - Not Printing Result

Mar 16, 2014

I'm new to C, and I'm trying to write a program that gets a string, divides it into terms and operators, reduces them and prints the result. I know the source code doesn't do exactly that, yet (specially the last part), but I'd like to compile it.

Code:
#include <stdio.h>
#include <string.h>
int main ()
{
/* Write a welcome message. */
printf ("
Calculator

I use Bloodshed Dev-C++ with Ming-W and I get quite a few errors when I try to compile it.

View 6 Replies View Related

C++ :: Mode In 2-D Array

May 2, 2014

I have to find mean,mode and median of a 2-D array :

2 5 2 5 9 5 8 3 6 10
8 1 10 10 7 1 4 4 3 8
4 3 1 2 4 10 3 9 8 5
6 10 8 3 6 10 5 1 2 5
2 2 9 2 5 5 1 1 7 5
7 9 9 2 1 5 2 2 2 4
3 6 1 9 3 4 10 7 4 6
7 10 4 6 2 10 10 8 7 6
7 1 3 6 2 4 6 7 8 9
8 5 9 2 3 2 1 5 1 8

I coded for mean but stuck for mode.

Code:
// Assign4_Q2.cpp : Defines the entry point for the console application.//

#include "stdafx.h"
#include<iostream>
#include<iomanip>
#include<conio.h>
using namespace std;

[Code] ......

View 10 Replies View Related

C# :: How To Get Monitor Out Of Sleep Mode

Jul 12, 2012

How can you get a monitor out of sleep mode in c#?

I tried the following, but then the monitor wakes up and falls back to sleep mode immediately.

Code:

uint SC_MONITORPOWER = 0xF170;
uint WM_SYSCOMMAND = 0x0112;
SendMessage(this.Handle, WM_SYSCOMMAND,
(IntPtr)SC_MONITORPOWER, (IntPtr)(-1));

View 1 Replies View Related

C :: Finding Mode Of Array

Mar 20, 2014

I've been trying for over an hour to think of the logic to find the mode of an array.I left out code for initializing the arrays, but all the values in the array are between 0-9. Check out my code below.

Code:

int mode( int array[], int size ) {
int i;
int count;
int max = 0;
int num = 0;
int mode;

[code]....

View 7 Replies View Related

C++ :: How To Find Mode In Array

Feb 6, 2014

How do you find a mode in array? This is what i got so far. I put this after i sort the array

for (int index = 0; index < size2; index ++) {
//count[mode[index] - 1]++;
if (mode[index] == mode[index + 1]) // compare the first to sec array {
again++;
cout <<"This is number " << again << endl;
}
}

View 1 Replies View Related

C++ :: Find Mode Of Vector Through Map?

Feb 16, 2015

Im currently trying to find the mode of a vector through a map but am not sure how to do so besides the attempt ive made

void mode(vector<double>v)
{
map<double, int> map;

[Code]....

View 3 Replies View Related

C/C++ :: Mode Of Sorted Array?

Sep 14, 2014

I've been working to make program to find the mode of sorted array. But the program didn't return the results correctly. Here is the code:

#include <iostream>
using namespace std;
int main () {
cout<<"Enter the size"<<endl;
int size;
cin>>size;
int data [size];

[code]....

View 14 Replies View Related

C++ :: Compute Mean / Median / Mode For Map Construct

May 28, 2013

I am writing code, which reads an input file (280 MB) containing a list of words. I would like to compute

1) total # of words
2) total # of unique/distinct words
3) mean/median/mode of word count (Link)

I managed to get done with 1) and 2), but my program crashes for 3). I am not quite sure whether there are memory issues or some bug in the code.

Code:
#include <iostream>
#include <fstream>
#include <string>
#include <map>
using namespace std;

[Code] .....

View 2 Replies View Related

C++ :: Finding Mode Of Numbers In Array

Sep 9, 2013

I have to use numbers in my .txt file that are stored in an array. So i have to write a function to find the mode of the numbers in my array.

View 5 Replies View Related

C++ :: How To Get The Current Video Mode In Console

Apr 2, 2014

I've been wondering if there's a function or procedure used to know the current video mode. An example of how this was done in Pascal:

function VideoMode : integer;
begin
if (lastmode = BW40) or (lastmode = BW80)
VideoMode := 40
else
VideoMode := 80;
end;

I've been told "conio.h" has a lastmode function, but it doesn't seem to be supported in Dev-C++ and Visual Studio C++. Is there a Windows function to know the number of columns in the current video mode?

View 1 Replies View Related

C/C++ :: Using Function To Find Mode Of Array?

Oct 20, 2014

My code seems to find the mode of the array I input sometimes. Sometimes it gives me the wrong number or multiple numbers. It just all depends on what is number is inputted into the array. I don't know what the problem is. I tried looking online and editing many times and can't find the answer. Maybe I'm overlooking something or doing something wrong. Here's my code.

#include <stdio.h>
void readArray(int arr[], int length)
{
printf("Enter data:
");

[Code].....

Maximum: 15
Mode: 2

As you can see the mode is clearly not 2 and I do not know why.

View 8 Replies View Related

C/C++ :: Find Mode Of Sorted Array

Sep 14, 2014

I've been working on my program to find mode of sorted array. But the program didn't return the res

#include <iostream>
using namespace std;
int main () {
cout<<"Enter the size"<<endl;
int size;
cin>>size;
int data [size];

[Code] ....

View 1 Replies View Related

C++ :: Calculate Mode / Mean And Median Of Array Of Integers

Mar 17, 2013

I'm writing a program that calculates the mode, mean and median of an array of integers. I've done the mean and median but i can't figure out mode.

I have to find the number of modes.

Ex array of integers: 10, 10, 4, 5, 6,5, 6, 7

My function has to return the number 3. Because there are 3 sets of mode; 10,5,6.

How do i implement this in my function because for now it just calculates the mode. It only return the number mode 10.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved