Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

http://www.cs.montana.edu/~sean.yaw/Teaching/Spring2017/111/Inlabs/Inlab5/Activi

ID: 3790490 • Letter: H

Question

http://www.cs.montana.edu/~sean.yaw/Teaching/Spring2017/111/Inlabs/Inlab5/Activity.pdf

The output should be like this

Problem Statement You are going to build an app that helps people decide what activity to do in Bozeman based on several factors (the desired intensity, the season, and whether or not they have health insurance). Users will call a method in your new class and pass values for those parameters to your code for activity determination and to decide whether or not they need to bring a friend Assignment Create a project called Inlab5. Copy this code into a class called Driver. Create the class ActivitySelector and make the two methods you need. (Hint: You don't need any instance variables, or even a constructor in the ActivitySelectorclass0 The activity determining method should employ switchiflif-else/if-else-if statements that follow this identification flowchart: l. Start with a switch statement on the intensity 2. When it is 0, print the only activity given for this intensity level 3. When it is 1, use an if else statement to determine if you should recommend hucking the diving board or hiking Triple Tree 4. When it is 2, follow the chart for the rest of the method Assume that each activity will fit in the chart somewhere (ie. spring time activities of intensity level 2) The bringFriendorNot method will print "Bring friend" if the intensity is 3 OR it is winter. It will print "No friend needed" if the person has insurance AND the intensity is at most 2. In al other cases, it will print "Travel solo at your own risk The bring FriendorNot method will of the form if else if thelset). No more than 2 "if s and 2 'else's Finally, add more calls to the ActivitySelector class to the Driver to test each of the possible activity outcomes you should have 9 activiti Don't worry about testing all possible bring FriendorNot outcomes. Your output should look similar to this. The specific values of bringFriendorNot will depend on specific parameters, so it may not be exact. You can also come up with a different way of saying what activity it is, just make sure the type is what it should be (ie. Spanish Peaks" or "Wax the skis! We're headed to the Spanish Peaks!" are both acceptable)

Explanation / Answer

public class ActivitySelector {

  

   public static void determineActivity(int intensity, String season, boolean insurance) {
       // TODO Auto-generated method stub
      
      
       switch(intensity){
      
       case 0:
           System.out.println("Easy day?");
           System.out.println("Hit the Hot Springs");
           break;
          
       case 1: System.out.println("Moderate day?");
       if(insurance==true)
       {
           System.out.println("Huck the driving board");
          
       }
       else
       {
           System.out.println("Hike Triple Tree");
       }
       break;
      
       case 2: System.out.println("Hard day?");
       if(season.equalsIgnoreCase("winter"))
       {
           System.out.println("snow on ground!!");
           System.out.println("Ski blaclmore");
       }
       else if(season.equalsIgnoreCase("summer"))
       { System.out.println("At least its summer");

           if(insurance==true)
           {
           System.out.println("North face of rose peak");
      
           }
           else
           {
               System.out.println("Run the ridge");
           }
       }
       else
       {
           System.out.println("Bozeman Triple Crown");
       }
       break;
       case 3: System.out.println("Epic day?");
       if(season.equalsIgnoreCase("summer"))
       {
           System.out.println("At least its summer");
           System.out.println("Granite peak in a day");

       }
       else if(season.equalsIgnoreCase("winter"))
       {
           System.out.println("Snows on ground!!");
           System.out.println("Spanish Peaks Traverse");

          
       }
       else
       {
           System.out.println("Better get in shape");
           System.out.println("Bozeman Triple crown");

       }
       break;
       default:
           System.out.println("pls enter intensity in range 0-3");
break;
   }
      
   }
   public static void bringFriendOrNot(int intensity, String season, boolean insurance) {
       // TODO Auto-generated method stub
      
      
       if(intensity==3|season.equalsIgnoreCase("winter"))
       {
           System.out.println("Bring friend");
       }
       else if(insurance==true&&intensity<=2)
       {
           System.out.println("No friend needed");
       }
       else
       {
           System.out.println("Travel solo at your on risk");
       }
      
   }


}

------------------------

package lab5;
/**
* Driver for the Activity Selection app.
*
* @author yaw
* @version 10 Feb 17
*/
public class Driver
{
public static void main(String[] args)
{
ActivitySelector.determineActivity(0, "winter", true);
ActivitySelector.bringFriendOrNot(0, "winter", true);
}
}