Skip Top Navigation Bar

Adopt-A-Pet

You are writing the code for an app for a virtual Pet.

First the person gets to name the pet. This will be the only input at this time.

Each pet starts with an initial energy level of 100. Energy is always a whole number.

You will provide the number of meals eaten, minutes of sleep, and exercise minutes for the pet as assignments to these variables, rather than input.

The program will announce the energy level of the pet in the following format:

Rusty has an energy level of 90

Step 1: Creating A Plan

Use the following questions as a guide to help you write your program.

Variables

An AI Minute, Let's Use AI!

Be sure to tell AI that you do not want it to provide you with any code at this time.

Give AI the initial prompt and provide it with the variables you have identified. Ask AI if it thinks you need any additional variables and why.

Here's a sample prompt: Do not provide any program code at this time. I have been asked to write the following program ___insert prompt_____. I've identified the following variables and types that I think I need. Are the data types for any of these variables incorrect or are there better types I should use and why? Are there additional variables you think I need and why? Are there any names that should be changed to be clearer and why?

Before making any updates to your plans, analyze what the AI provided by asking yourself these questions:

Do you agree with their suggestions, or is what you wrote more accurate?

Do the suggested variable name changes result in more readable code or are the variables you selected just as good?

Input and Output

Step 2: Writing the Program

Open up your IDE and begin writing your program. A good place to start your program is to break it into four stages:

The following template uses this model to help you get started. You can copy this template into a new .java file.

The // symbol creates comments that are ignored by the compiler. We will learn more about comments in a future lesson.