about | help | code help+videos | done | prefs |
Write a method that may or may not double a number, then may or may not square that result. If 'dub' is 'true' then you double the input parameter 'num', otherwise you keep the value of 'num'. Then, after that, if 'sqr' is 'true' you square the result, otherwise keep the previous result. For example, with the input parameters (5,false,false) you would return a 5 because you didn't do anything to the 5. However, if the input parameters were (5,true,false) you would return 10, having doubled the 5. If the input parameters were (5,false,true) you would return 25, having squared 5. In the case of (5,true,true) you would first double 5 to get 10, then square that to get 100. Look at the test data for examples. Remember, you can only have ONE return statement per method. practiceQuiz2021_08_30_APSLHL_dubSqr(8, false, true) → 64 practiceQuiz2021_08_30_APSLHL_dubSqr(9, false, true) → 81 practiceQuiz2021_08_30_APSLHL_dubSqr(3, true, true) → 36 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 250
Copyright Nick Parlante 2017 - privacy