Section12.10Unit 1a Subgoal Labeled Puzzles for Toggle Code
These are copies of the Mixed Up Code Practice 1a puzzles with subgoal labels added. The Unit 1a Toggle Code Practice page uses them as the Get Help puzzles for its write code problems. Problems whose solution has fewer than two subgoals keep the original, unlabeled puzzle.
The following program segment should figure out the cost for each shirt if they are buy 2 and get the third free and they are originally $45 each. But, the blocks have been mixed up. Drag the blocks from the left and put them in the correct order on the right. Click the Check button to check your solution.
// Store the original price per shirt
double price = 45;
---
// Find the total paid for three shirts
double totalCost = price * 2;
---
// Find the total paid for three shirts
double totalCost = price * 3; #paired
---
// Split the total paid equally among the shirts
double pricePerShirt = totalCost / 3;
---
// Display the cost per shirt
System.out.println(pricePerShirt);
The following program segment should figure out the cost per person for a dinner including the tip. But the blocks have been mixed up and may include an extra block that isnβt needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check button to check your solution.
// Store the bill
double bill = 89.23;
---
// Find the tip as a percent of the bill
double tip = bill * 0.20;
---
// Find the tip as a percent of the bill
double tip = bill * 20; #paired
---
// Raise the bill by the tip
double total = bill + tip;
---
// Split the total equally among the people
double perPersonCost = total / 3;
---
// Display the cost per person
System.out.println(perPersonCost);
---
// Display the cost per person
System.out.println(perpersoncost); #paired
The main method in the following class should print the number of seconds in 5 days. But, the blocks have been mixed up and may include an extra block that isnβt needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check button to check your solution.
public class Test1
{
---
public static void main(String[] args)
{
---
// Store the time conversion rates
int sInMin = 60;
int mInHour = 60;
int hInDay = 24;
---
// Combine the rates into seconds per day
int sInDay = sInMin * mInHour * hInDay;
---
// Combine the rates into seconds per day
int sInDay = sInMin + mInHour + hInDay; #paired
---
// Use a rate to change days to seconds
int total = sInDay * 5;
---
// Display the number of seconds
System.out.println(total);
---
} // end main method
---
} // end of class
The main method in the following class should calculate the number of months it would take you to save 500 if you make 50 a week. But, the blocks have been mixed up and may include an extra block that isnβt needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check button to check your solution.
public class Test1
{
---
public static void main(String[] args)
{
---
// Store the savings goal, weekly pay, and weeks per month
double weeklyRate = 50;
double goal = 500;
double weeksPerMonth = 4;
---
// Store the savings goal, weekly pay, and weeks per month
int weeklyRate = 50;
int goal = 500;
int weeksPerMonth = 4; #paired
---
// Use a rate to change dollars to weeks
double numWeeks = goal / weeklyRate;
---
// Use a rate to change weeks to months
double numMonths = numWeeks / weeksPerMonth;
---
// Display the number of months
System.out.println(numMonths);
---
} // end main method
} // end of class
The main method in the following class should calculate the cost of a trip that is 200 miles when the price of gas is 2.20 and the miles per gallon is 42. But, the blocks have been mixed up and may include an extra block that isnβt needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check button to check your solution.
public class Test1
{
---
public static void main(String[] args)
{
---
// Store the trip distance, gas price, and miles per gallon
int miles = 200;
double price = 2.20;
int mpg = 42;
---
// Use a rate to change miles to gallons
double numGalls = (double) miles / mpg;
---
// Use a rate to change miles to gallons
double numGalls = (double) (miles / mpg); #paired
---
// Use a rate to change gallons to dollars
double totalCost = numGalls * price;
---
// Display the cost of the trip
System.out.println(totalCost);
---
// Display the cost of the trip
System.println(totalCost); #paired
---
} // end main method
---
} // end of class
The main method in the following class should calculate how many miles you can go on half a tank of gas if the miles per gallon is 26 and your tank holds 15 gallons. But, the blocks have been mixed up and may include an extra block that isnβt needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check button to check your solution.
public class Test1
{
---
public static void main(String[] args)
{
---
// Store the miles per gallon and the tank size
int mpg = 26;
int tankHolds = 15;
---
// Find the gallons in half a tank
double numGalls = (double) tankHolds / 2;
---
// Find the gallons in half a tank
double numGalls = tankHolds / 2; #paired
---
// Use a rate to change gallons to miles
double miles = numGalls * mpg;
---
// Display the miles you can go
System.out.println(miles);
---
} // end main method
---
} // end of class
The main method in the following class should calculate how many chicken wings you can buy with $3.50 if the wings are $.60 each. But, the blocks have been mixed up and may include an extra block that isnβt needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check button to check your solution.
public class Test1
{
---
public static void main(String[] args)
{
---
// Store the money you have and the price per wing
double cost = 0.6;
double money = 3.5;
---
// Store the money you have and the price per wing
int cost = 0.6;
int money = 3.5; #paired
---
// Use a rate to change dollars to wings
double exactWings = money / cost;
---
// Convert the number of wings to an integer
int numWings = (int) exactWings;
---
// Convert the number of wings to an integer
int numWings = exactWings; #paired
---
// Display the number of wings
System.out.println(numWings);
---
} // end main method
---
} // end of class
The main method in the following class should calculate how much you will have to pay for an item that is 60% off the original price of $52.99. But, the blocks have been mixed up and may include an extra block that isnβt needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check button to check your solution.
public class Test1
{
---
public static void main(String[] args)
{
---
// Store the original price and the percent off
double price = 52.99;
double discount = 0.6;
---
// Find the savings as a percent of the price
double savings = price * discount;
---
// Lower the original price by the savings
double finalPrice = price - savings;
---
// Display the price you pay
System.out.println(finalPrice);
---
// Display the price you pay
System.out.println(savings); #paired
---
} // end main method
---
} // end of class
The main method in the following class should calculate how much the per item costs is for shorts that are buy 2 and get the third free. The shorts are $39.99 each. But, the blocks have been mixed up and may include an extra block that isnβt needed in the solution. Drag the needed blocks from the left and put them in the correct order on the right. Click the Check button to check your solution.
public class Test1
{
---
public static void main(String[] args)
{
---
// Store the original price per pair of shorts
double price = 39.99;
---
// Find the total paid for three pairs of shorts
double priceForTwo = price * 2;
---
// Find the total paid for three pairs of shorts
double priceForTwo = price * 2 #paired
---
// Split the total paid equally among the shorts
double itemPrice = priceForTwo / 3;
---
// Split the total paid equally among the shorts
double itemPrice = priceForTwo / 2; #paired
---
// Display the cost per pair of shorts
System.out.println(itemPrice);
---
} // end main method
---
} // end of class