1/3
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No study sessions yet.
1AA
public MessageBuilder(String startingWord)
{
message = startingWord;
String w = getNextWord(startingWord);
numWords = 1;
while (w != null)
{
message += " " + w;
numWords++;
w = getNextWord(w);
}
}
1AB
int onesPlace = downloads % 10;
int remainingNum = downloads / 10;
int count = 0;
int checkNum;
while (remainingNum > 0)
{
checkNum = remainingNum % 10;
if (checkNum == onesPlace)
{
count++;
}
remainingNum = remainingNum / 10;
}
if (count == 1)
{
System.out.println("exactly once");
}
else
{
System.out.println("not exactly once");
}
1B
int posDash = songInfo.indexOf("-");
String artist = songInfo.substring(0, posDash);
String remaining = songInfo.substring(posDash + 1);
posDash = remaining.indexOf("-");
String song = remaining.substring(posDash + 1);
System.out.println(song + " by " + artist);
2A
public void simulateOneDay(int numBirds)
{
if (Math.random() < 0.95)
{
// Generate food eaten per bird: 10, 20, 30, 40, or 50
int foodPerBird = (int) (Math.random() 5 + 1) 10;
int totalFoodEaten = numBirds * foodPerBird;
if (totalFoodEaten <= currentFood)
{
currentFood -= totalFoodEaten;
}
else
{
currentFood = 0;
}
}
else // abnormal conditions: bear
{
currentFood = 0;
}
}