Using Java, create functions that return specific values listed below. MUST use integer only, functions, loops, conditionals. Money has to be stored as two different integers, one integer for dollars and another for cents. No use of double :
String moneyToString(int d, int c); // Returns the Money as words. Ex, moneyToString(10,24) => "$10.24"
void printSum(int d1, int c1, int d2, int c2); // Prints the sum of
monies. Ex, printSum(10,24,3,90) => print "$14.14"
int biggestMoney(int d1, int c1, int d2, int c2, int d3, int c3);
// Returns which money is biggest.
Ex, biggestMoney(10,24,3,90,1,23) => 1
Ex, biggestMoney(3,90,1,23,10,24) => 3
void printChangeFrom20(int d, int c);
// You may assume you always pay with $20, you always owe a
positive amount that is <= $20.
// If you owe $5.12 and pay with $20.00, your change should be
$14.88
// If you owe $3.91 and pay with $20.00, your change should be
$16.09
public class MyClass {
public static String moneyToString(int d, int c){
return "$"+Integer.toString(d)+"."+Integer.toString(c);
}
public static void printSum(int d1, int c1, int d2, int c2)
{
int d = d1 + d2;
int c = c1 + c2;
if(c >= 100)
{
d++;
c -= 100;
}
System.out.println(moneyToString(d, c));
}
public static void main(String args[]) {
System.out.println(moneyToString(10, 24));
printSum(10, 24, 3, 90));
}
}
// Please note that we are allowed to answer only 2
parts of the coding questions per post. So, post
accordingly.
Using Java, create functions that return specific values listed below. MUST use integer only, functions, loops,...
Using Java, create functions that return specific values listed below. MUST use integer only, functions, loops, conditionals. Money has to be stored as two different integers, one integer for dollars and another for cents. No use of double : String moneyToString(int d, int c); // Returns the Money as words. Ex, moneyToString(10,24) => "$10.24" int biggestMoney(int d1, int c1, int d2, int c2, int d3, int c3); // Returns which money is biggest. Ex, biggestMoney(10,24,3,90,1,23) => 1 Ex, biggestMoney(3,90,1,23,10,24) =>...