*MUST BE IN C PROGRAMMING*
Write a simple program that allows the user to enter a number between 1 and 1000. The program will then display the Roman numeral equivalent. Allow the user to keep entering numbers for conversion to Roman numerals, or to quit, using a menu system of your own design.
Submission Requirements:
You are to write a good solution - as short, concise, and clever as possible.
#include <stdio.h>
/* Global data to store roman values */
char roman_data[1000];
int i = 0;
void pre(char n1, char n2)
{
roman_data[i++] = n1;
roman_data[i++] = n2;
}
void post(char data, int num)
{
int j;
for (j = 0; j < num; j++) {
roman_data[i++] = data;
}
}
char *roman(long int data)
{
int j;
long int num;
num = data;
if (num <= 0 || num > 1000) {
return NULL;
}
/* repeat the loop until num becoms zero */
while (num != 0) {
if (num >= 1000) {
/* num greater than 1000 */
post('M', num / 1000);
num = num - (num / 1000) * 1000;
} else if (num >= 500) {
/* num greater than 500 */
if (num < (500 + 4 * 100)) {
post('D', num / 500);
num = num - (num / 500) * 500;
} else {
pre('C','M');
num = num - (1000-100);
}
} else if (num >= 100) {
/* num greater than 100 */
if (num < (100 + 3 * 100)) {
post('C', num / 100);
num = num - (num / 100) * 100;
} else {
pre('L', 'D');
num = num - (500 - 100);
}
} else if (num >= 50 ) {
/* num greater than 50 */
if (num < (50 + 4 * 10)) {
post('L', num / 50);
num = num - (num / 50) * 50;
} else {
pre('X','C');
num = num - (100-10);
}
} else if (num >= 10) {
/* num greater than 10 */
if (num < (10 + 3 * 10)) {
post('X', num / 10);
num = num - (num / 10) * 10;
} else {
pre('X','L');
num = num - (50 - 10);
}
} else if (num >= 5) {
/* num greater than 5 */
if (num < (5 + 4 * 1)) {
post('V', num / 5);
num = num - (num / 5) * 5;
} else {
pre('I', 'X');
num = num - (10 - 1);
}
} else if (num >= 1) {
/* num greater than 1 */
if (num < 4) {
post('I', num / 1);
num = num - (num / 1) * 1;
} else {
pre('I', 'V');
num = num - (5 - 1);
}
}
}
roman_data[i]='\0'; /* Add null character at end of the string
*/
return(roman_data);
}
int main()
{
int long val;
char *ptr;
char choice;
while(1){
printf("Enter the number to convert into Roman: Or
-1 to Quit\n");
scanf("%ld",&val);
if(val == -1){
break;
}
ptr = roman(val);
if(ptr == NULL){
printf("NUmber Not in the
range\n");
}else{
printf("Roman number is:
%s\n",ptr);
}
roman_data[0]='\0';
i = 0;
}
return 0;
}

*MUST BE IN C PROGRAMMING* Demonstrate the ability to think critically Demonstrate the ability to work...
* C PROGRAMMING* Outcomes: Demonstrate the ability to create and use linked lists in dynamic memory Demonstrate the ability to add nodes and remove nodes from a linked list of structs Program Specifications: Write a program that creates the following struct (you can give it whatever name you want): char name[100]; int age; float weight; Create the following menu system: Add a Record Display All Records Quit When the user selects (1) you will prompt them for a name, age,...
The following needs to be in C programming ! Outcomes: Demonstrate the ability to design a menu driven program. Demonstrate the ability to reuse previous code to create a new assignment. Demonstrate the ability to use appropriate program logic. Program Specifications: DESIGN and IMPLEMENT a menu driven program that uses the following menu and can perform all menu items: Enter a payroll record for one person Display all paycheck stubs Display total gross payroll from all pay records. Quit program...
*KEEP IT SIMPLE PLEASE* Write a program that allows the user to convert any integer number to Roman numeral and the other way around. - You should create and print a menu that allows the user to select either Roman to Int or Int to Roman. - If one option is selected then you should promote the user to enter the number and then you print the equivalence in the other system. - Validate input, i.e Roman numerals should be...
Java Programing Code only Ragged Array Assignment Outcome: Student will demonstrate the ability to create and use a 2D array Student will demonstrate the ability to create and use a jagged array Student will demonstrate the ability to design a menu system Student will demonstrate the ability to think Program Specifications: Write a program that does the following: Uses a menu system Creates an array with less than 25 rows and greater than 5 rows and an unknown number of...
object oriented programming:Write a program that converts a number entered in decimal toRoman numerals. Your program should consist of a class, say, romanType. Anobject of type romanType should do the following:a. Store the number as a decimal.b. Convert and store the number into roman form.c. Print the number as a Roman numeral or decimal number as requestedby the user.The decimal values of the Roman numerals are:M 1000D 500C 100L 50X 10V 5I 1
***************C PROGRAMMING ONLY************* Demonstrate the ability to create an array on the stack Demonstrate the ability to create an array on the heap allowing user to choose the number of values to store. Demonstrate the ability to store an array of Struct values on both the stack and the heap. Program Specifications: 1. Create a struct with at least 3 fields - any struct you want but explain it in your comments in the code. Populate at least 10 elements...
Methods and File Output and Exceptions Outcome: Student will demonstrate the ability to write, use and call methods Student will demonstrate the ability to pass values to and from methods Student will demonstrate the ability to catch exceptions Student will demonstrate the ability to create a text file Student will demonstrate the ability to validate input data Program Specifications: You to write a menu driven program. The program will use a switch statement. The cases will be as follows: Get...
Write this program using C++ , (Rock, Paper, Scissors Game – Page 373) This programming assignment is from the textbook with some slight modifications and clarifications. Here is what I am going to except from you. Your program should include at least the following functions: getComputerGuess(): this function should return a random value generated by the computer using rand function (read more about random numbers in Chapter 3 pages 126 – 128). getUsersChoice(): this function will ask the user to...
Write a menu driven program to demonstrate the use of array and switch. It must be written in C language . Here is the menu - Press 1 to add a number to the array. Press 2 to display the numbers entered in the array so far Press 3 to find the average of the numbers entered. Press 4 to exit. Option 1 - The user should be able to enter 20 numbers only. If all twenty numbers are entered...
Lab 4: Java Fundamentals, Part IV In this assignment, you solve a conversion problem similar to Programming Challenge 1 of Chapter 3 of your text, page 184 (187 in Edition 5). Given one of the Roman numerals I, II, III, IV, V, VI, VII, VIII, IX, X, XI, XII, XIII, XIV, XV as an input your program must determine and display the corresponding decimal digit 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15....