Zelaron Gaming Forum

Zelaron Gaming Forum (http://zelaron.com/forum/index.php)
-   Tech Help (http://zelaron.com/forum/forumdisplay.php?f=329)
-   -   Need help (http://zelaron.com/forum/showthread.php?t=24510)

Medieval Bob 2003-11-20 06:41 PM

Ugh comments suck. Can I do it tomorrow?

Hades-Knight 2003-11-21 04:15 PM

Ok its already 1 day, times up

Medieval Bob 2003-11-21 06:07 PM

Well, I don't feel like doin it now. Also, I'm not your bitch, so... if I decide to do it later, I might.

Hades-Knight 2003-11-23 04:38 PM

puh-lease can you do it now?

Hades-Knight 2003-11-24 06:32 PM

due tomorrow help with comments!!!

Hades-Knight 2003-11-24 09:05 PM

Can you add some comments and edit these to fit the criteria? kthx




#include<stdio.h>
#include <iostream.h>
int main() //Main function
{
int i; //Define variables
int previous = 0;
int num;
int total = 0;
int flag = 0;
int key = 0;
int repeat = 1;
char roman[50]; //defines roman char for input
char roman2[50]; //defines roman char for output
char pchar = 'z';

cout << "Enter the Roman numeral(in caps!!): "; //prompt for user input
cin >>roman;

for (i = 0; i < 50; i++) //count what the input value range is
{

if (roman[i] == 'M') //assigns 1000 to input M
num = 1000;
else if (roman[i] == 'D') //assigns 500 to input D
num = 500;
else if (roman[i] == 'C') //assigns 100 to input C
num = 100;
else if (roman[i] == 'L') //assigns 50 to input L
num = 50;
else if (roman[i] == 'X') //assigns 10 to input X
num = 10;
else if (roman[i] == 'V') //assigns 5 to input V
num = 5;
else if (roman[i] == 'I') //assigns 1 to input I
num = 1;
else if (roman[i] == '\0') //if input is 0 flag=1 for error
flag = 1;


/****************************Start Calculation for order of input******************/
/* If input has a value next to it, it checks to see if its more or less than first */
/* If it has less value than the one to the right, substract, if it has higher value add */
if (num == previous)
repeat = repeat + 1;
else
repeat = 1;

if (repeat == 4 && num == 1)
{

flag = 1;
}
if (repeat == 2 && num == 5)
{

flag = 1;
}
if (repeat == 4 && num == 10)
{

flag = 1;
}
if (repeat == 2 && num == 50)
{

flag = 1;
}
if (repeat == 4 && num == 100)
{

flag = 1;
}
if (repeat == 2 && num == 500)
{

flag = 1;
}

if (flag == 0)
{


if (num > previous)
{
if (key == 1)
{

i = 50;
}
total = (total - (2 * previous)) + num;
key = 1;
}
else
total += num;

previous = num;
num = 0;
}
else
{

i = 50;
}

}


cout<<total << endl; //Output the calculated number given that roman characters are calculated right
/*******************************START DOUBLING****************************************/
total = total * 2; //doubles the number you got from convertion
repeat = 1;

for (i = 0; i < 50; i++)
{ //Given then total in int , assign character to each int value

if (total >= 1)
roman2[i] = 'I';
if (total >= 5)
roman2[i] = 'V';
if (total >= 10)
roman2[i] = 'X';
if (total >= 50)
roman2[i] = 'L';
if (total >= 100)
roman2[i] = 'C';
if (total >= 500)
roman2[i] = 'D';
if (total >= 1000)
roman2[i] = 'M';
if (total == 0)
roman2[i] = '\0';

if (roman2[i] == pchar)
repeat = repeat + 1;
else
repeat = 1;

if (repeat == 4 && roman2[i] == 'I')
{
roman2[i - 2] = 'V';
roman2[i - 1] = '\0';
}

if (roman2[i] == 'M') // After getting the range value calculate exact value by substracting the value character to the left
total -= 1000; //and assign character to integer value , convertion.
else if (roman2[i] == 'D')
total -= 500;
else if (roman2[i] == 'C')
total -= 100;
else if (roman2[i] == 'L')
total -= 50;
else if (roman2[i] == 'X')
total -= 10;
else if (roman2[i] == 'V')
total -= 5;
else if (roman2[i] == 'I')
total -= 1;
else if (roman2[i] == '\0')
i = 50;

pchar = roman2[i];
}

cout<<roman2; //outputs the double value in roman characters

return(0);
}

WetWired 2003-11-24 09:26 PM

You could just do it yourself, you know. Ask someone from your class. And if you can't find anyone in your class who can do it, you can hope to be graded on a curve.

Medieval Bob 2003-11-24 09:32 PM

Don't know what all you want done... How's this?


#include<stdio.h>
#include <iostream.h>
int main() //Main function
{
int i; //Define variables
int previous = 0;
int num;
int total = 0;
int flag = 0;
int key = 0;
int repeat = 1;
char roman[50]; //defines roman char for input
char roman2[50]; //defines roman char for output
char pchar = 'z';

cout << "Enter the Roman numeral(in caps!!): "; //prompt for user input
cin >>roman;

for (i = 0; i < 50; i++) //count what the input value range is
{

if (roman[i] == 'M') //assigns 1000 to input M
num = 1000;
else if (roman[i] == 'D') //assigns 500 to input D
num = 500;
else if (roman[i] == 'C') //assigns 100 to input C
num = 100;
else if (roman[i] == 'L') //assigns 50 to input L
num = 50;
else if (roman[i] == 'X') //assigns 10 to input X
num = 10;
else if (roman[i] == 'V') //assigns 5 to input V
num = 5;
else if (roman[i] == 'I') //assigns 1 to input I
num = 1;
else if (roman[i] == '\0') //this is the end of input

/****************************Start Calculation for order of input******************/
/* If input has a value next to it, it checks to see if its more or less than first */
/* If it has less value than the one to the right, substract, if it has higher value add */
if (num == previous)
repeat = repeat + 1;
else
repeat = 1;

if (repeat == 4 && num == 1)
{

flag = 1;
}
if (repeat == 2 && num == 5)
{

flag = 1;
}
if (repeat == 4 && num == 10)
{

flag = 1;
}
if (repeat == 2 && num == 50)
{

flag = 1;
}
if (repeat == 4 && num == 100)
{

flag = 1;
}
if (repeat == 2 && num == 500)
{

flag = 1;
}

if (flag == 0)
{


if (num > previous)
{
if (key == 1)
{

i = 50;
}
total = (total - (2 * previous)) + num;
key = 1;
}
else
total += num;

previous = num;
num = 0;
}
else
{

i = 50;
}

}


cout<<total << endl; //Output the calculated number given that roman characters are calculated right
/*******************************START DOUBLING****************************************/
total = total * 2; //doubles the number you got from convertion
repeat = 1;

for (i = 0; i < 50; i++)
{ //Given then total in int , assign character to each int value

if (total >= 1)
roman2[i] = 'I';
if (total >= 5)
roman2[i] = 'V';
if (total >= 10)
roman2[i] = 'X';
if (total >= 50)
roman2[i] = 'L';
if (total >= 100)
roman2[i] = 'C';
if (total >= 500)
roman2[i] = 'D';
if (total >= 1000)
roman2[i] = 'M';
if (total == 0)
roman2[i] = '\0';

if (roman2[i] == pchar)
repeat = repeat + 1;
else
repeat = 1;

if (repeat == 4 && roman2[i] == 'I') //I has been repeated too many times
{
roman2[i - 2] = 'V';
roman2[i - 1] = '\0';
}

if (roman2[i] == 'M') // After getting the range value calculate exact value by substracting the value character to the left
total -= 1000; //and assign character to integer value , convertion.
else if (roman2[i] == 'D')
total -= 500;
else if (roman2[i] == 'C')
total -= 100;
else if (roman2[i] == 'L')
total -= 50;
else if (roman2[i] == 'X')
total -= 10;
else if (roman2[i] == 'V')
total -= 5;
else if (roman2[i] == 'I')
total -= 1;
else if (roman2[i] == '\0')
i = 50;

pchar = roman2[i];
}

cout<<roman2; //outputs the double value in roman characters

return(0);
}


All times are GMT -6. The time now is 08:28 AM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
This site is best seen with your eyes open.