Comp Sci

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall with Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/3

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No study sessions yet.

4 Terms

1
New cards

1AA

public MessageBuilder(String startingWord)

{

message = startingWord;

String w = getNextWord(startingWord);

numWords = 1;

while (w != null)

{

message += " " + w;

numWords++;

w = getNextWord(w);

}

}

2
New cards

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");

}

3
New cards

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);

4
New cards

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;

}

}