Closed bishwobista closed 1 year ago
assign it to me
assign it to me
sure, go ahead.
Here you go!
``import java.util.Scanner;
public class IntegerToRoman { public String intToRoman(int num) { String[] thousands = {"", "M", "MM", "MMM"}; String[] hundreds = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"}; String[] tens = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"}; String[] ones = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};
return thousands[num / 1000] + hundreds[(num % 1000) / 100] + tens[(num % 100) / 10] + ones[num % 10];
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
IntegerToRoman converter = new IntegerToRoman();
System.out.print("Enter an integer: ");
int num = scanner.nextInt();
String romanNumeral = converter.intToRoman(num);
System.out.println("Roman Numeral: " + romanNumeral);
}
}``
How would I merge this?
Here you go!
``import java.util.Scanner;
public class IntegerToRoman { public String intToRoman(int num) { String[] thousands = {"", "M", "MM", "MMM"}; String[] hundreds = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"}; String[] tens = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"}; String[] ones = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};
return thousands[num / 1000] + hundreds[(num % 1000) / 100] + tens[(num % 100) / 10] + ones[num % 10]; } public static void main(String[] args) { Scanner scanner = new Scanner(System.in); IntegerToRoman converter = new IntegerToRoman(); System.out.print("Enter an integer: "); int num = scanner.nextInt(); String romanNumeral = converter.intToRoman(num); System.out.println("Roman Numeral: " + romanNumeral); }
}``
How would I merge this?
You need to fork the repo -> clone it in your computer -> create a remote branch -> push the commits -> and send a Pull Request. Or just follow along a tutorial on YouTube. If there are any other issues, let me know. Good Luck ✌️
Got it, thank you!!
Given an integer, convert it to a roman numeral using Java language.