1. Write a header with an appropriate return type and parameters. 2. Write the body with curly braces. 3. Declare a variable that matches the return type and initialize it with a placeholder value. 4. Return that variable.
Help me solve this problem
Multiple Choice & Some Date Fashion
When writing methods, always write the method skeleton first and make sure it compiles.
1. Write a header with an appropriate return type and parameters.
2. Write the body with curly braces.
3. Declare a variable that matches the return type and initialize it with a placeholder value.
4. Return that variable.
With practice, these
Practice these steps and then solve the DateFashion problem using sequential if statements along with the return statement. The idea is to get more practice with multi-branch logic. Therefore, don't use any of the binary Boolean operators like && or ||. You may use the Boolean not operator (!).
https://codecheck.it/files/1810031754ckr22amvk7fr6jtdrtqgrmqle
![```java
/**
* This file contains logic problems for CS 170.
*
* @author (your name goes here)
* @version (place the date here)
* Logic problems for CS 170.
* @author
* @version
*/
public class DateFashion
{
/**
* Write the method dateFashion().
*
* You and your date are trying to get a table at
* a restaurant. The parameter "you" is the stylishness
* of your clothes, in the range 0..10, and "date" is
* the stylishness of your date's clothes. The result
* of getting the table is encoded as an int value with 0 = no,
* 1 = maybe, and 2 = yes.
*
* If either of you is very stylish, (8 or more), then
* the result is 2 (yes). With the exception that if
* either of you has style of 2 or less, then the result
* is 0 (no). Otherwise, the result is 1 (maybe).
*
* Some examples:
* dateFashion(5, 10) returns 2
* dateFashion(5, 2) returns 0
* dateFashion(5, 5) returns 1
*
* @param you the style quotient for your clothes.
* @param date the style quotient for your date's clothes.
* @return chances of getting a table (0-no, 1-maybe, 2-yes).
*/
// TODO Write the dateFashion method here
...
}
```
### Explanation:
The provided Java class outlines a logic problem designed for CS 170. It includes a commented structure that guides the implementation of a method called `dateFashion()`. This method determines the likelihood of getting a table at a restaurant based on the stylishness of your attire and your date's attire.
- **Parameters**:
- `you`: An integer representing your style quotient (0 to 10).
- `date`: An integer representing your date's style quotient (0 to 10).
- **Return Values**:
- `0`: You will not get a table.
- `1`: You might get a table.
- `2`: You will definitely get a table.
The rules for](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F9e418959-67e0-447a-9763-9bd078026b55%2F3e2a88d9-3873-40f3-9e50-2bc8c4a89098%2F8cfbz8d_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
public class Datefashion{
// two parameters as specified you and date as int as values ranging from 0 to 10
//we are going to return as integer
public int dateFashion(int you, int date) {
int result=1; //this was no condition value
if(you>=8 || date>=8) //if any of them has style greater than or equal to 8
result=2; //set the result to 2
else if(you<=2 || date<=2) //if any of them has style lesser than or equal to 2
result=0; //set the result to 0
return result; //returnig result
}
}
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)