How would I write this program?
public class TeaTimes { } /** * We are having a party with amounts of tea and candy. * Return the int outcome of the party encoded as * 0-bad, 1-good, or 2-great. A party is good (1) if * both tea and candy are at least 5. However, if * either tea or candy is at least double the amount * of the other one, the party is great (2). However, * in all cases, if either tea or candy is less than 5, * the party is always bad (0). * * @param tea amount of tea * @param candy amount of candy @return outcome of the party */ // TODO: Write method teaParty here... /** * The chemistry club is having an afternoon tea time with * tea and candy. They wish to do a fun chemistry experiment * with their tea and candy before consuming it. Each time *they run their experiment, the amount of candy increases *by a given percentage. * Given the weight of tea and weight of candy they started * with, return the number of times they need to run the * experiment for the weight of candy to exceed the weight * of tea. Return -1 if the experiment will never increase * the candy. * * @param tea starting weight of tea @param candy starting weight of candy * @param percent percentage of candy growth each experiment run @return number of times experiment runs to have more candy than tea */ // TODO: Write method teaTimes here...
How would I write this program?
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am