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


ADVERTISEMENT

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 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 :: 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++ :: 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++ :: 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 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/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 :: 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++ :: 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++ :: Program With Do-while Loop To Restart Program And Validation

May 11, 2013

I am having problems at the end of the program with the do-while loop to restart the program and the validation.

#include <iostream>
#include <string>
#include <iomanip>
#include <cstdlib>
#include <time.h>
using namespace std;

[code]....

View 3 Replies View Related

C/C++ :: Program Which Removes Notes From Program File

Mar 10, 2014

so my homework assignment is to make a program of which removes any notes in a program file.

for example, you run my program it will ask for a filename, when entered it opens the file, copies everything in it and removes any double forward slashes (//) and anything after that up to the new line character ( ) and anything between /* and */ including the /* and */.

i created the entire program and it removed the // and anything after that up to the new line character but will not remove anything after the first / when it finds a /*. This includes the */ at the end of the comment.

the section of code that removes the comments is

//this loop removes all notes
for(i=0;i<buf.st_size;i++) {
if((filecontent[i]=='/')&&(filecontent[i+1]=='/'))//removes notes using //
{
for(i=i;filecontent[i]!='
';i++)
filecontent[i]=' ';}

[Code]....

i know that the section that removes the multi line comments would not remove the final */ at the end if it did work, i was planning to fix that later once it removed the comment.

View 6 Replies View Related

C++ :: Transform Program To Program Using Class

May 15, 2014

I have my program to load info about students from .txt file

Mrkvicka Jozef 2 1.75 2.1 0.4 1 0.49 1.27
Hrasko Jan 0.1 0.38 1 1.2
Mladek Peter 1.6 0.4 2 1.3 1.8
Petrzlen Robert 0.6 0 1.1 1.1 0.6 0.59
Horvath Ivan 1.6 0.8 0.7 1.3 1

My program is ruuning perfectly only problem is that i must transform it to program uses class, class student . Am very beginer in using classes, so far i do very easy programs using classes.

so far i have this

#include "stdafx.h"
#include "student.h"
student::student(vector<STUDENT> studenti) {
vStudent=studenti;

[Code] ....

I try to make it but its too difficult for me. in that student.h and student .cpp is 50 errors..

Here is my code

#include "stdafx.h"
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <fstream>
using namespace std;

[Code] ....

View 13 Replies View Related

Visual C++ :: Program Run In Another Program

Jul 22, 2014

I want to make a program which can run in another program. My program have structures flowing:

while (1) {
check (keypressed);
{
do something;
}
}

But check(keypressed) function only active in my program, It can't run in another program.

View 7 Replies View Related

C++ :: SDL - Can't Run Program Outside Of IDE

Sep 4, 2013

I've been working on a small SDL program and decided I wanted to throw the program on to a disc so I could show some people what I'm working on. However, when I try to run the executable, the program crashes and under more details it says that the fault lies on SDL2_ttf.dll .

Why does this program work inside of VS2012e and not in windows?

What I did :

Set the program to release, hit f6, and then tried to run the executable from windows.

Additional information :

Compiler : Visual Studio 2012 express
O/S : Windows 7 64bit
SDL lib : 32 bit version

View 8 Replies View Related

C :: How To Get Program To Write Itself

Aug 27, 2013

For instance Code: int counter;
counter =0;
FILE *pfile;
pfile= fopen("g:myprog.txt" "w");
while (counter >100)
{ fprintf (case counter{something})}; how do I do this?

View 11 Replies View Related

C :: How To Get Average Of Program

Mar 20, 2013

Cannot divide the real output of the AVERAGE.:

Code:

#include<stdio.h>
#include<conio.h>
struct student
{
char Name[50];

[Code]....

View 7 Replies View Related

C :: How To Get Output Of Program

Dec 8, 2013

how to get the output of this program.. I'm not completely lost but I need it in the simplest terms.

Code:

/*Recursive Trace
Written by Ron
April 2006
*/

[Code]....

View 9 Replies View Related

C :: Have A Program Where It Ask For Three Numbers

Feb 1, 2013

is there anyway to have a program where it ask for three numbers and you shows which which number is the largest and which is the smallest, e.g.

Enter 1st number: 30
Enter 2nd number: 10
Enter 3rd number: 30
Largest = 30
Smallest = 10

View 12 Replies View Related

C :: Natural Log Program

Oct 16, 2014

I am working on a program to compute the natural log of numbers using several different methods, but I am having a couple of issues. Firstly, when using Borchardt's Algorithm I almost always end up with nan as a result, even though I am pretty sure I got the formula correct. Also, in my lnDemo.c file It doesnt give me the correct answer and the second time around I get a segmentation fault.

Code:

//myLog.h-------------------------------------------------------
//These functions will compute or aproximate the natural log of a number
//This method will use a formula to compute it
int lnFormula(double x, int m,double *result);

[code]....

View 7 Replies View Related

C :: Program Is Not Terminated

Feb 26, 2014

I have written the below code,

#include "stdio.h"
int main() {
int c;
while((c=getchar()) != EOF) {
putchar(c);
}
}

The above program is not terminated.how to terminate it?

View 3 Replies View Related

C# :: How To Add More Than One Database In A Program

Mar 5, 2014

Is it possible to add more than one database in a C# program if so, how?

View 7 Replies View Related

C :: Program That Runs On A PC But Not On Another

Mar 6, 2015

I'va create a c program that scans the web from a root it works on mypc but dont works on another pc of my friend.I have created this project with Visual Studio 2013 disabling extension to obtain standard ansi c project.

View 2 Replies View Related

C :: Age Identifier Program?

Jul 2, 2013

I have an issue with a switch case in my program. I execute it and it does fine all the way up to where it says, "Answer (1, 2, or 3): ". When I enter 1, 2, or 3, it gives me' "Not an input choice!" from the default of the switch case.

NOTE: I use Code::Blocks on Windows XP.

Here is the code:

Code:

#include <stdio.h>
#include <string.h>
int main() {

[Code].....

View 8 Replies View Related







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