Question

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"


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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1- public class MyClass { public static String moneyToString(int d, int c){ return $ Integer.toString(d)+.+Integer.toStri

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.

Add a comment
Know the answer?
Add Answer to:
Using Java, create functions that return specific values listed below. MUST use integer only, functions, loops,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 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) =>...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT