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

Hey guys jus halfway finished my review for my test tomorrow was lookin for some

ID: 3563013 • Letter: H

Question

Hey guys jus halfway finished my review for my test tomorrow was lookin for some help on these. they are sample questions for what could be on the test. Thanks

                int luckySum(int a, int b, int c) {

                }

                However: if one of the values is 13, then that value does not count towards the sum      AND all values to its right do not count. For example, if b is 13, then both b and c do not         count.

                returns a double for the average, that is the sum of the parameters divided by 3:

                int guess = in.nextInt();

                if(guess == x)   System.out.print("Success!!");

                else{

                if(guess < x)   System.out.print("Smaller than X");

                else                           System.out.print("Larger than X");

                System.out.println("... Try again");

                }

    num *= x;                       

2) (x < 2) && (x > 1)     

3) (++x < 2) || (x < 1)

Explanation / Answer

Part 1

/**
* @(#)ReviewTomorrow.java
*
*
* @author
* @version 1.00 2014/9/25
*/

public class ReviewTomorrow {

    public void printAverage(int x,int y,int z)
    {  
       System.out.println("Average is : "+((double)(x+y+z)/3));    // return double type casted average value
    }
    public double average(int x,int y,int z)
    {  
       return ((double)(x+y+z)/3);    // return double type casted average value
    }
    public double divide(int x,int y)
    {
       if(y==0)
           return 0;
       return ((double)(x)/y);           // return double type casted divide value
    }
    public int luckySum(int a,int b,int c)
    {
       if(a==13)
           return 0;           // if a==13 return 0
       else if(b==13)
            return a;           // if b==13 return a
        else if(c==13)
            return a+b;           // if c==13 return a+b
        else
            return a+b+c;        // if no one is 13 then return a+b+c
    }
    public static void main(String args[])
    {
       ReviewTomorrow rv1=new ReviewTomorrow();
       rv1.printAverage(10,15,20);
       System.out.println("Divide is : "+rv1.divide(15,2));
       System.out.println("Divide is : "+rv1.divide(15,0));
       System.out.println("Lucky Number is : "+rv1.luckySum(13,25,15));
       System.out.println("Lucky Number is : "+rv1.luckySum(15,13,25));
       System.out.println("Lucky Number is : "+rv1.luckySum(15,25,13));
       System.out.println("Lucky Number is : "+rv1.luckySum(15,25,10));
    }
}

--------------------Configuration: <Default>--------------------
Average is : 15.0
Divide is : 7.5
Divide is : 0.0
Lucky Number is : 0
Lucky Number is : 15
Lucky Number is : 40
Lucky Number is : 50

Process completed.

Part 2

int guess = in.nextInt();
if(guess == x)
{
    System.out.print("Success!!");
}
else
{
    if(guess < x)
    {
        System.out.print("Smaller than X");
    }
    else
    {
        System.out.print("Larger than X");
    }
    System.out.println("... Try again");
}