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
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)
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.
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;
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.
i'm making a program that, given a person's birthdate or any other date, will display the day of the week of the person was born.
There is this part where it says "use a switch statement to make this calculation, If desired month is 12, add the number of days for November, if desired month is 11 add the number of days for october....
So it's suppose to start with "case 12 :...
I can't figure out what to write for the statement....
I have two date/time structures which I'm populating, but when I populate the second one it sets the same values in the first. This is what I've got so far
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.
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.
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();
#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.
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
Currently I am working on a program where you enter in a date 14 03 2013 (Day, Month, Year) and you get the next day. I seem to be coming stuck with months with less than 31 days, and the whole leap year thing. Here is my code so far.
Code: #include <stdio.h> int day, month, year, next_day, next_month, next_year, calculation; int main() { printf("Enter a date in the form day/month/year: "); scanf("%d %d %d", &day, &month, &year);
If I am asked to declare a data type for Date which should be in the format DD/MM/YY, which data type should i use for it? Is there any data type known as Date in C?
How can I check for an invalid date when I run the program? I am trying to enter a conditional statement that checks for a valid or invalid date.
Programing Question: Write a program that inputs a date (e.g., July 4, 2008) and outputs the day of the week that corresponds to that date. Here is what I Have. The program runs. I need it to loop around.
#include <iostream> using namespace std; const int JANUARY = 1; const int FEBRUARY = 2; const int MARCH = 3; const int APRIL = 4;
I'm doing a daily time record that record every inputed date on a txt file how will have an option or how will I delete a some of the choosen date? i'm using C++
So I have a programming assignment which is for getting a user input in the format of m/d/yyyy. This is stored as d/m/yyyy. I have been able to code all the rest of the requirements of the program but the thing that is giving me trouble is this. The year is allowed to go from 1-3000. The format of the displayed date is:
a zero-filled, two-digit day number, a dash, full name of month, a dash, zero-filled, four-digit year.
I am able to use a switch statement in order to get my name of the month. What I am struggling to figure out is the whole zero filled two digit day and zero filled four digit year. From the way the input is store it appears to me that it will be stored as yyyy which means if you were to enter 0001 for year 1 then it should output it as that (this is an assumption based on format). What I don't get is that the day is entered and stored as d which means if you put in 12 how would it be stored. However if you put in 6 to print the output I would need to add a zero and I dont know how to do that either.
Here is the code for getting the input. The function must stay formated this way as per the instructor. The / is stored but ignored hence the char for second and fourth since / is a char
Code: void getDate (int& day, int& month, int& year){ char second; char fourth; cout << "Please enter a date in the format of m/d/yyyy" << endl; cin >> month >> second >> day >>fourth >> year; }
Is there any way to do date math using standard C libraries? I looked around in the time.h but didn't see what I needed.
What I need to do is be able to add a certain number of minutes to a date and have it give the current date/time. For example, add 15918765 minutes to 01/01/1980 00:00 and have it tell me 04/07/2010 4:45PM. I really don't want to write this myself or go platform-specific.