.. qnum::
   :prefix: 1-8-
   :start: 1

Mixed Up Code Practice
==============================

Try to solve each of the following mixed-up code problems or try the experimental switch between mixed up or write code versions of these problems on the next page instead.

For these mixed up code problems, drag the blocks into the correct order. Click the *Check Me* button to check each solution.  You will be told if your solution is too short, has a block in the wrong order, or you are using the wrong block.  Some of the problems may have an extra block that isn't needed in the correct solution. After 3 tries, you can ask for help and some of the blocks will be combined. You can solve these on your phone or other mobile device!

.. parsonsprob:: ch4ex1muc
        :numbered: left
        :practice: T
        :adaptive:
        :noindent:

        The following program segment should print Maria's first name on one line and her last name on the next line.  But, the blocks have been mixed up and include an extra block that isn't needed in the solution.  Drag the blocks from the left and put them in the correct order on the right.  Click the Check button to check your solution.
        -----
        String firstName = "Maria";
        String lastName = "Hernandez";
        =====
        System.out.println(firstName);
        =====
        System.out.println(lastName);
        =====
        System.out.printlln(firstname); #distractor



.. parsonsprob:: ch4ex2muc
        :numbered: left
        :practice: T
        :adaptive:
        :noindent:

        The following program segment should print the words to a famous poem. 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.
        -----
        System.out.println("Roses are red");
        =====
        System.out.println("Violets are blue");
        =====
        System.out.println("Sugar is sweet");
        =====
        System.out.println("And so are you");


.. parsonsprob:: ch4ex3muc
   :numbered: left
   :practice: T
   :adaptive:
   :noindent:

   The main method in the following class should print Marcus's name on one line and his favorite color on the next line. But, the blocks have been mixed up and 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)
       {
   =====
           String name = "Marcus";
           String color = "Blue";
   =====
           System.out.println(name);
   =====
           System.out.println(color);
   =====
       } // end main method

   =====
   } // end of class
   =====
           System.out.println(Name); #distractor


.. parsonsprob:: ch3ex1muc
   :numbered: left
   :practice: T
   :adaptive:
   :noindent:

   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.
   -----
   double price = 45;
   =====
   double totalCost = price * 2;
   =====
   double pricePerShirt = totalCost / 3;
   =====
   System.out.println(pricePerShirt);


.. parsonsprob:: ch3ex2muc
   :numbered: left
   :practice: T
   :adaptive:
   :noindent:

   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.
   -----
   double bill = 89.23;
   =====
   double tip = bill * 0.20;
   =====
   double total = bill + tip;
   =====
   int numPeople = 3;
   double perPersonCost = total / numPeople;
   =====
   System.out.println(perPersonCost);
   =====
   System.out.println(perpersoncost); #distractor



.. parsonsprob:: ch3ex4muc
   :numbered: left
   :practice: T
   :adaptive:
   :noindent:

   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)
       {
   =====
           int sInMin = 60;
           int mInHour = 60;
           int hInDay = 24;
   =====
           int sInDay = sInMin * mInHour * hInDay;
   =====
           int total = sInDay * 5;
   =====
           System.out.println(total);
   =====
       } // end main method
   =====
   } // end class
   =====
   public Class Test1
   { #distractor

.. parsonsprob:: ch3ex5muc
   :numbered: left
   :practice: T
   :adaptive:
   :noindent:

   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)
       {
   =====
           double weeklyRate = 50;
           double goal = 500;
   =====
           double numWeeks = goal / weeklyRate;
   =====
           double numMonths = numWeeks / 4;
   =====
           System.out.println(numMonths);
   =====
       } // end main method
   } // end class
   =====
       public void main(String[] args)
       { #distractor


.. parsonsprob:: ch4ex5muc
   :numbered: left
   :practice: T
   :adaptive:
   :noindent:

   The main method in the following class should print the name on one line followed by the age on the next line. But, the blocks have been mixed up and 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)
       {
   =====
           String name = "Layla";
           String age = "16";
   =====
           System.out.println("Your name is " + name);
   =====
           System.out.println("Your age is " + age);
   =====
       } // end main method
   =====
   } // end class
   =====
           System.out.println("Your age is " age); #distractor


.. parsonsprob:: ch4ex6muc
   :numbered: left
   :practice: T
   :adaptive:
   :noindent:

   The main method in the following class should print the name on one line and the favorite food on the next line. But, the blocks have been mixed up and 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)
   =====
       {
   =====
           String name = "Julian";
           String food = "chicken wings";
   =====
           System.out.println("Your name is " + name);
   =====
           System.out.println("Your favorite food is " + food);
   =====
       }
   =====
   }
   =====
           System.println("Your name is " + name); #distractor


.. parsonsprob:: ch3ex6muc
   :numbered: left
   :practice: T
   :adaptive:
   :noindent:

   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)
   =====
       {
   =====
           int miles = 200;
           double price = 2.20;
           int mpg = 42;
   =====
           double numGalls = (double) miles / mpg;
   =====
           double totalCost = numGalls * price;
   =====
           System.out.println(totalCost);
   =====
       }
   =====
   }
   =====
           System.println(totalCost); #distractor

.. parsonsprob:: ch3ex7muc
   :numbered: left
   :practice: T
   :adaptive:
   :noindent:

   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)
   =====
       {
   =====
           int mpg = 26;
           int tankHolds = 15;
   =====
           double numGalls = (double) tankHolds / 2;
   =====
           double miles = numGalls * mpg;
   =====
           System.out.println(miles);
   =====
       }
   =====
   }
   =====
       public static main(String[] args) #distractor

.. parsonsprob:: ch3ex8muc
   :numbered: left
   :practice: T
   :adaptive:
   :noindent:

   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)
   =====
       {
   =====
           double cost = 0.6;
           double money = 3.5;
   =====
           int numWings = (int) (money / cost);
   =====
           System.out.println(numWings);
   =====
       }
   =====
   }
   =====
           int cost = 0.6;
           int money = 3.5; #distractor

.. parsonsprob:: ch3ex9muc
   :numbered: left
   :practice: T
   :adaptive:
   :noindent:

   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)
   =====
       {
   =====
           double price = 52.99;
           double discount = 0.6;
   =====
           double savings = price * discount;
   =====
           double finalPrice = price - savings;
   =====
           System.out.println(finalPrice);
   =====
       }
   =====
   }
   =====
           int price = 52.99;
           int discount = 0.6; #distractor

.. parsonsprob:: ch3ex10muc
   :numbered: left
   :practice: T
   :adaptive:
   :noindent:

   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)
   =====
       {
   =====
           double price = 39.99;
   =====
           double priceForTwo = price * 2;
   =====
           double itemPrice = priceForTwo / 3;
   =====
           System.out.println(itemPrice);
   =====
       }
   =====
   }
   =====
           double priceForTwo = price * 2 #distractor


