Big Idea 1 Lesson 1.6
Popcorn Hack 2
public class PopcornHack2 {
public static void main(String[] args) {
int score = 100;
System.out.println("Starting score: " + score);
// Deduct points for a wrong answer
score -= 20;
System.out.println("After wrong answer (-=20): " + score);
// Double the score with a power-up
score *= 2;
System.out.println("After power-up (*=2): " + score);
// Find remainder after dividing by 7
score %= 7;
System.out.println("After dividing by 7 (%=7): " + score);
}
}
int score = 100;
System.out.println("Starting score: " + score);
// Deduct points for a wrong answer
score -= 20;
System.out.println("After wrong answer (-=20): " + score);
// Double the score with a power-up
score *= 2;
System.out.println("After power-up (*=2): " + score);
// Find remainder after dividing by 7
score %= 7;
System.out.println("After dividing by 7 (%=7): " + score);
Starting score: 100
After wrong answer (-=20): 80
After power-up (*=2): 160
After dividing by 7 (%=7): 6
Homework Hack
public class SocialMediaSimulator {
public static void main(String[] args) {
System.out.println("=== SOCIAL MEDIA SIMULATOR ===\n");
// Starting stats
int followers = 500;
int posts = 0;
int engagement = 0;
int sponsorshipEarnings = 0;
int position = 800;
System.out.println("Starting followers: " + followers + "\n");
// Posted a new video
posts++;
followers += 250; // viral growth
engagement += 70; // likes/comments
System.out.println("Posted a new video!");
System.out.println("Followers: " + followers + " (+250 from the viral video)\n");
// Controversial opinion posted
followers -= 50;
System.out.println("Controversial opinion posted...");
System.out.println("Followers: " + followers + " (-50 from upset followers)\n");
// Trending hashtag boost
followers *= 2; // double followers
engagement *= 2; // double engagement
System.out.println("Trending hashtag boost!");
System.out.println("Followers: " + followers + " (doubled from trending!)\n");
// Average engagement per post
double avgEngagement = (double) engagement / posts;
System.out.println("Average engagement per post: " + avgEngagement + "\n");
// Sponsorship earnings
sponsorshipEarnings += 500;
System.out.println("Sponsorship earnings so far: $" + sponsorshipEarnings + "\n");
// Ranking position
position %= 500; // simulate ranking
System.out.println("Final ranking position: " + position + "\n");
System.out.println("=== SIMULATION COMPLETE ===");
}
}
System.out.println("=== SOCIAL MEDIA SIMULATOR ===\n");
// Starting stats
int followers = 500;
int posts = 0;
int engagement = 0;
int sponsorshipEarnings = 0;
int position = 800;
System.out.println("Starting followers: " + followers + "\n");
// Posted a new video
posts++;
followers += 250; // viral growth
engagement += 70; // likes/comments
System.out.println("Posted a new video!");
System.out.println("Followers: " + followers + " (+250 from the viral video)\n");
// Controversial opinion posted
followers -= 50;
System.out.println("Controversial opinion posted...");
System.out.println("Followers: " + followers + " (-50 from upset followers)\n");
// Trending hashtag boost
followers *= 2; // double followers
engagement *= 2; // double engagement
System.out.println("Trending hashtag boost!");
System.out.println("Followers: " + followers + " (doubled from trending!)\n");
// Average engagement per post
double avgEngagement = (double) engagement / posts;
System.out.println("Average engagement per post: " + avgEngagement + "\n");
// Sponsorship earnings
sponsorshipEarnings += 500;
System.out.println("Sponsorship earnings so far: $" + sponsorshipEarnings + "\n");
// Ranking position
position %= 500; // simulate ranking
System.out.println("Final ranking position: " + position + "\n");
System.out.println("=== SIMULATION COMPLETE ===");
=== SOCIAL MEDIA SIMULATOR ===
Starting followers: 500
Posted a new video!
Followers: 750 (+250 from the viral video)
Controversial opinion posted...
Followers: 700 (-50 from upset followers)
Trending hashtag boost!
Followers: 1400 (doubled from trending!)
Average engagement per post: 140.0
Sponsorship earnings so far: $500
Final ranking position: 300
=== SIMULATION COMPLETE ===