Program.cpp
#include <iostream>
#include <bits/stdc++.h>
#include<fstream>
using namespace std;
int whole_xber_array[35];
string roman_array1[35],roman_array2[35];
string toLongRoman(int x){
int decimal[] =
{1000,900,500,400,100,90,50,40,10,9,5,4,1}; //base values
const char *symbol[] =
{"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
//roman symbols
int i = 0;
string s="";
while(x){ //repeat process until x is not
0
while(x/decimal[i]){
//first base value that divides x is largest base value
s+=symbol[i];
x -= decimal[i]; //subtract largest base value from x
}
i++;
//move to next base value to divide x
}
return s;
}
string toLower(string s){
transform(s.begin(),s.end(),s.begin(),::tolower);//convert string
to lowercase
return s;
}
int main()
{
ofstream oFile;
oFile.open("roman.txt");
int x,index=0;
do{
x=-1;
do{
cout<<"Enter the number ";
cin>>x;
}while(x<0 || x>5000);
string s=toLongRoman(x);
cout<<s<<endl;
if(x!=0) {
whole_xber_array[index]=x;
roman_array1[index]=s;
roman_array2[index]=toLower(s);
index++;
}
}while(x!=0);
string s="number\tRoman\tRoman small\n";
cout<<s;
oFile<<s;
for(int i=0;i<index;i++){
cout<<whole_xber_array[i]<<"\t"<<roman_array1[i]<<"\t"<<roman_array2[i]<<endl;
oFile<<whole_xber_array[i]<<"\t"<<roman_array1[i]<<"\t"<<roman_array2[i]<<"\n";//write
to file
}
oFile.close();//close file
return 0;
}
Output
Assignment Draw a flowchart, using Microsoft Visio or LucidChart, to document the logic required to complete...
Can someone code this asap? Use any language that you want. 2. Ancestral Names Given a list of strings comprised of a name and a Roman numeral, sort the list first by name, then by decimal value of the Roman numeral. In Roman numerals, a value is not repeated more than three times. At that point, a smaller value precedes a larger value to indicate subtraction. For example, the letter I represents the number 1, and Vrepresents 5. Reason through...
*Answer must be in C* Write a complete program as follows (declare any necessary variables): Create an array of doubles named “hummus” with 2 rows and 300 columns. Initialize all array elements to zero. Write a loop that will repeatedly ask the user to enter a value and store it in the first row of the array (do not overwrite previously entered values) until the whole first row is populated with the user input. (hint the loop should have the...
Write a menu based program implementing the following functions: (0) Write a function called displayMenu that does not take any parameters, but returns an integer representing your user's menu choice. Your program's main function should only comprise of the following: a do/while loop with the displayMenu function call inside the loop body switch/case, or if/else if/ ... for handling the calls of the functions based on the menu choice selected in displayMenu. the do/while loop should always continue as long...
Please complete the following programming with clear explanations. Thanks! Homework 1 – Programming with Java: What This Assignment Is About? Classes (methods and attributes) • Objects Arrays of Primitive Values Arrays of Objects Recursion for and if Statements Selection Sort Use the following Guidelines: Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc.) Use upper case for constants. • Use title case (first letter is upper case) for classes. Use lower case with uppercase...
I need help as quick as possible, thanks beforehand. Please provide the test output The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown below. 35 The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 - 9 exactly The sum of each row, each column and each diagonal all add up to the same number. This is shown below: 15 4 92 15 - 81 + 15 15 15...
Using java : In this exercise, you need to implement a class that encapsulate a Grid. A grid is a useful concept in creating board-game applications. Later we will use this class to create a board game. A grid is a two-dimensional matrix (see example below) with the same number of rows and columns. You can create a grid of size 8, for example, it’s an 8x8 grid. There are 64 cells in this grid. A cell in the grid...
In this assignment, we will be making a program that reads in customers' information, and create a movie theatre seating with a number of rows and columns specified by a user. Then it will attempt to assign each customer to a seat in a movie theatre. 1. First, you need to add one additional constructor method into Customer.java file. Method Description of the Method public Customer (String customerInfo) Constructs a Customer object using the string containing customer's info. Use the...
Objectives Work with functions Assignment Write each of the following functions using Python. The function header MUST be written as specified. In your main code test all of the specified functions. Each function must have a comment block explaining what it does, what the parameters are and what the return value is. Please remember the following two guidelines: unless the purpose of the function is to generate output DO NOT write to the screen within the function unless the purpose...
DESCRIPTION Complete the program using Java to read in values from a text file. The values will be the scores on several assignments by the students in a class. Each row of values represents a specific student's scores. Each column represents the scores of all students on a specific assignment. So a specific value is a specific student's score on a specific assignment. The first two values in the text file will give the number of students (number of rows)...