/** * In this method, you will place a (very limited) Chipotle order based on th
ID: 3730685 • Letter: #
Question
/**
* In this method, you will place a (very limited) Chipotle order based on the
* input. The return String should be "Bowl with ____ rice and ____ fajita
* veggies and _____ salsa.", where the blanks are filled using the instructions
* below. If the boolean guac is true, add a space and "Guac please." at the
* end.
*
* For examples, please see the public tests. You may assume all inputs will be
* valid.
*
* @param rice
* 'b' or 'B' for "brown", 'w' or 'W' for "white"
* @param fajitas
* 0 for "no", <10 for "some", >=10 for "a lot of"
* @param salsa
* 1 for "pico", 2 for "verde", 3 for "corn"
* @param guac
* whether the bowl should have guac or not
* @return the order as described above
*/
public static String chipotleOrder(char rice, int fajitas, int salsa, boolean guac) {
Explanation / Answer
/** * In this method, you will place a (very limited) Chipotle order based on the * input. The return String should be "Bowl with ____ rice and ____ fajita * veggies and _____ salsa.", where the blanks are filled using the instructions * below. If the boolean guac is true, add a space and "Guac please." at the * end. * * For examples, please see the public tests. You may assume all inputs will be * valid. * * @param rice * 'b' or 'B' for "brown", 'w' or 'W' for "white" * @param fajitas * 0 for "no", =10 for "a lot of" * @param salsa * 1 for "pico", 2 for "verde", 3 for "corn" * @param guac * whether the bowl should have guac or not * @return the order as described above */ public static String chipotleOrder(char rice, int fajitas, int salsa, boolean guac) { String r, f, s, q; if(rice == 'b' || rice == 'B') { r = "brown"; } else if(rice == 'w' || rice == 'W') { r = "white"; } else { r = ""; } if(fajitas == 0) { f = "no"; } else if(fajitas < 10) { f = "some"; } else { f = "a lot of"; } if(salsa == 1) { s = "pico"; } else if(salsa == 2) { s = "verde"; } else if(salsa == 3) { s = "corn"; } else { s = ""; } String str = String.format("Bowl with %s rice and %s fajita veggies and %s salsa.", r, f, s); if(guac) { str += " Guac please."; } return str; }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.