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
ADVERTISEMENT
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
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
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
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
Aug 28, 2014
Working on a project for a c++ class and got a bit stuck.
What I am trying to do is include a class for calculating home square footage in a program I have written for my last project. When I do this, I get errors in codeblocks, on lines 74 and 87, "expected ; before 'box', and 'box' was not declared, respectively. Unsure what my snafu is... I had these two programs separate and both run without errors until I combine the two into one program.
View 2 Replies
View Related
Jan 22, 2014
I have a project which does a specific thing, like an open file dialog.
I would like to open it in a different project on a click of a button.
Also, It has a different namespace.
I'm guessing that it would involve a "using" statement to add the namespace And I will have to add reference to an *.exe or *.dll -> I'll have to look up how to make a *.dll, I know where the *.exe file is.
I have searched for a different things on Google, but I don't think that I am looking for the correct phrase (which is always frustrating...)
View 12 Replies
View Related
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
Nov 19, 2014
how to convert integers -> Roman Numerals using both if & switch statement.
View 3 Replies
View Related
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
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
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
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
Oct 5, 2013
I have an array of (Student)classes created in Manager.h, which contains a new instance of class Name (name),(in Student.h)How would I go about accessing the SetFirstName method in Name.cpp if I was in a class Manager.cpp? I have tried using Students[i].name.SetFirstName("name");
// In Manager.h
#include"Student.h"
class Manager
{
[Code]....
View 2 Replies
View Related
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
Apr 5, 2013
I have to do a project for Programming and he said in quotes
"Programming exercise 10.6: the programming project is as described, except do not represent the points using structures.
Assume, as known, the ten (x,y)-values corresponding to x=0.0, 0.1, 0.3, 0.45 ..etc and use y-values from the
function xsin(x); as in (x,y)=(x, xsin(x)) = (0.3, 0.3sin(0.3)).
Use value n+1=10, so the LaGrange polynomial will be order = 9."
What does it mean to not represent the points using structures??
View 2 Replies
View Related
May 28, 2013
I have project that is on c++. it runs fine. i want to use it in my C# application as a dll. i have created its dll and but firing exception of "interprocess communication".
Is this a doable task that creating dll of an exe project and using it in C# application?
View 1 Replies
View Related
Feb 21, 2013
At the moment im trying to integrate an dll in my project (first time).
I copy the lib and dll to my project-directory and the header to my include path.
Now i get a linker error:
1>LINK : fatal error LNK1181: cannot open input file "libWebSvcTx.obj"
the dll calls libWebSvcTx.dll.
I insert the libWebSvcTx.lib to the Dependencies.
Don't know whats the mention of the output and how to avoid it...
View 1 Replies
View Related
Aug 29, 2012
How I can connect BoxedApp.dll for my C# - project?Is it real?
View 4 Replies
View Related
Feb 24, 2015
I'm pretty new to C++ and I'm on Binary Trees in "Jumping into C++"! I've just created a DLL project on Code::Blocks, and I cannot get it to build and run: "You must select a host application to "run" a library..." is the message that I'm getting when I run the main code file. It's had no changes to it (except for a few extra, unnecessary line feeds), and it's the file which Code::Blocks generates on a DLL project.
View 13 Replies
View Related
Dec 6, 2014
I am having a problem with the duplication of a line I'm outputting from a file. Whenever I run the program the last line in the "New accounts" portion is always repeated. Here is my code for reference:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
[Code].....
View 3 Replies
View Related
Apr 4, 2013
I have a Visual C++ solution file that contains 3 projects. i want to access the variables declared in a function in a project from a function in another project. Function declarations are in .h file and expansion in .cpp files. Can i use friend class or any other suitable method.
View 6 Replies
View Related
Feb 27, 2014
I am writing a program that has many header files and their corresponding implementation files. I collected all the header files in a folder and did same for the implementation files into another folder. I'm using the Dev C++ IDE; I could add the files one by one to the project. Instead of doing this however, I tried adding the two folders to the project; but, the project did not compile!! The compiler could not find the files resident in each of the folders!
How I can add the folders to the project so that the internal files are visible to the compiler; or do I have to go the longer route of adding the internal files individually??
View 4 Replies
View Related
Jun 5, 2014
I had a project to create an ATM with a database of 100 customers, i wasn't able to interface the real program with the database. I have submitted the project already. Here is the database and the ATM program
#include <stdio.h>
int main(void) {
int account, pin;
[Code]....
View 1 Replies
View Related
Aug 17, 2014
I am building a log4net wrapper project where I reference log4net.dll. When calling this code through a static instance to log messages the new project also wants me to reference log4net.dll even though I have a reference to my logging project which in turn has the reference..
View 2 Replies
View Related
Jul 16, 2012
I have a project ALT in C++. I want to check IP from file text , compare with url string . But I don`t known how to call it?
// BhoApp.cpp : Implementation of CBhoApp
#include "stdafx.h"
#include "BhoNew.h"
#include "BhoApp.h"
#include "exdispid.h"
/////////////////////////////////////////////////////////////////////////////
// CBhoApp
#include <iostream>
#include <fstream>
[Code] ....
Using code line 30-59 and line 98-109 ?
View 1 Replies
View Related