Pet Recommender
You have been asked to build a program that recommends whether a person should get a dog or a cat based on the following input values:
- Is there a backyard or not? Input should be
yesfor backyard andnofor no backyard. - How much outside activity do you want to spend? Input is an integer value.
- How many hour are you out of the house each day? Input is an integer value.
Cat vs. Dog
Dogs require time outside and lots of socialization. Your progam should recommend a dog:
- if the person has a background and an outside activity time greater than 60 minutes or the time they spend outside the home is less than 8 hours
- if the person does not have a backyard, but has an outside activity time greater than 60 minutes and the time they spend outside the home is less than 8 hours. In all other cases, recommend a cat.
Determine Test Cases
Develop test cases for all the different combinations the Boolean expressions will evaluate to and the results of these values. There are 3 Boolean conditions, how many different combinations are needed?
Edge Cases
When testing a relational operator comparison, you will want to provide values that are less than, greater than, as well as equal to the value you are comparing to. This ensures that you are testing the edge case as well as on either side. What are the edge cases that need to be tested?
Algorithm
Write your algorithm for this program. Include the input, output, conditions that will be needed. Will you need one-way selection, two-way selection, or nested if statements?
Trace Your Algorithm
Use truth tables to trace through the logic of the conditional to ensure that proper type of pet is being recommended. Make adjustments if any of the results do not match the requirements.
Ask AI
There are multiple ways you can structure your conditional. Now that yours has been thoroughly tested, let's see what AI would come up with and compare these expressions.
|
An AI Minute, Let's Use AI! |
|
Give AI the initial prompt and provide it with your conditional. Here's a sample prompt: I have been asked to write the following program ___insert prompt_____. I've developed the following conditional statement to determine the type of pet to recommend. Provide an alternate conditional statement. Determine which conditional statement is best to use and explain why. Before making any updates to your plans, analyze what the AI provided by asking yourself these questions: Do you agree with their suggestion? Which conditional statement do you think is the best and why? Did AI suggest any new structures that you haven't learned yet? Ask AI for another equivalent conditional statement that uses the structures you have learned. |
Write Your Program in an IDE
Now that you have planned out your program, it's time to write it in your IDE. Since this program requires input values, use of the Java Playground is not an option.
Create a PetRecommender.java file for your main program file. Add your algorithm to the body of the main method in the starter code provided.