In Exercise P3.26 you were asked to write a program to convert a number to its r
ID: 3674102 • Letter: I
Question
In Exercise P3.26 you were asked to write a program to convert a number to its representation in Roman numerals. At the time, you did not know how to eliminate duplicate code, and as a consequence the resulting program was rather long. Rewrite that program by implementing and using the following method: .. P5.21 public static String romandigit(int n, String one, String five, String ten) That method translates one digit, using the strings specified for the one, five, and values. You would call the method as follows: "1", "V", "X"); romanOnes- n=n/10: romanDigitin % 10, romanTens = romanDigit(n % 10, "X", "L", "C"); Business P5.2 Write a method that computes the balance of a bank account with a given initial balance and interest rate, after a given number of years. Assume interest is com- pounded yearly . Bucinoss ps 22 Wita nrogram that prints instructions to get coffee, asking the user for whenever a decision needs to be made. Decompose each task into a method, for example: public static void brewCoffeeO System.out.println("Add water to the coffee maker."); System.out.println("Put a filter in the coffee maker."); grindCoffeeO; System.out.println("Put the coffee in the filter.";Explanation / Answer
}
--------------------------------------------------------------------------------------------------------------------------------------
public class P5_22 { public static double computeBalance(double init_balance, double interest, int years) { return init_balance * Math.pow((1 + interest), years); }}
--------------------------------------------------------------------------------------------------------------------------------------