I got a 55/66 on my 66 question quiz. Below are some questions that I got wrong and why:

66: In the given for loop, j is initially 1 and increases by 2 repeatedly as long as it is less than 10. In this while loop (the correct answer), j is initially 1 and increases by 2 repeatedly while it is less than 10. Both code segments produce the output 13579.44

53: The total variable should be initialized to 1 for both parts of the code to work properly. This is because it allows for the second part of the code snippet to run properly, as it manipulates the variable total.

35: The original code segment prints 10. This code segment prints 11 because the loop executes 11 times. The loop iterates 10 times. In each iteration, count is incremented by 1. Since the initial value of count is 0, the printed value of count is 10.

34: The original code segment prints the sum of twice the value of the elements in the array. This code segment prints a value that is twice the sum of the integers from 0 to arr.length - 1. The original code segment uses an enhanced for loop to iterate through the elements of array arr, uses variable sum to accumulate the sum of twice the value of the elements in the array, and prints the value of sum. This code segment produces the same output using a regular for loop. As the index k varies from 0 to arr.length - 1, twice the value of arr[k] accumulates in the variable sum.

32: Initializing the length count between lines 12 and 13 will allow the program to run as intended.

28: The method call will work as intended: since there are no instances of 1 in the list, the list will remain unchanged after the call. The method does not work as intended when there are consecutive occurrences of low_score in scores. When the first instance of 3 at index 3 is removed, the elements that follow it are shifted left, resulting in [8, 8, 4, 3, 6]. The next element, which is also equal to 3, moves to index 3. But j is incremented to 4 after the removal, so the second instance of 3 is not removed from the list.

20: The given code segment prints 1357, while this code segment prints 0246. The given code segment starts when k is 1 and prints every other value as long as k is less than or equal to 7. This code segment starts when k is 1 and prints every other value as long as k is less than or equal to 8. Both code segments print 1357.

19: The expressions are not equivalent when a has the value 4, b has the value 3, c has the value 2, and d has the value 1. By De Morgan's laws, the given expression is equivalent to (a < b) || (c < d).

=-b-&&-c-==-d-for-the-case-when-"cat"-should-be-printed." aria-hidden="true">18: In order to apply De Morgan’s laws and negate the condition in the if statement in the given code segment, the logical operator should be changed from || to &&. As an example, if a, b, c, and d have the values 1, 2, 2, and 2, respectively, then the given code segment would print "dog" and this code segment would print "cat". Since the original expression prints "dog" when a < b || c != d evaluates to true, an equivalent code segment would print "cat" when the negative of the expression, or !(a < b || c != d), evaluates to true. Applying De Morgan’s laws produces the equivalent Boolean expression a >= b && c == d for the case when "cat" should be printed.

14: The opposite of greater than is less than or equal. Therefore, the opposite of (b > 7) is (b <= 7). De Morgan’s Law states that !(p && q) is equivalent to !p || !q. By applying De Morgan’s Law to this expression, we negate the first expression !(!(a !=b)) and the second expression !(b >7) to form !(!(a != b)) || !(b > 7). In the first expression the two consecutive not operators (!) cancel each other out giving us (a != b). In the second expression, the opposite of > is <= giving us (b <= 7). The equivalent expression is (a != b) || (b <= 7).

5: Correct Sequence for De Morgans.

// imports allow you to use code already written by others.  It is good to explore and learn libraries.  The names around the dots often give you a hint to the originator of the code.
// these are objects
import java.util.Scanner; //library for user input 
import java.lang.Math; //library for random numbers
// java style to import library
double mass;
double accel;
double Force;
double ac;
double m;
double m1;
double m2;
double mod1;
double mod2;
double result;


public class Menu {
    // Instance Variables
    public final String DEFAULT = "\u001B[0m";  // Default Terminal Color // final = not going to change, static means element is not changing (not part of the object)


    // Constructor on this Object takes control of menu events and actions
    public Menu() {
        Scanner sc = new Scanner(System.in);  // using Java Scanner Object
        
        this.print();  // print Menu
        boolean quit = false;
        while (!quit) {
            try {  // scan for Input
                int choice = sc.nextInt();  // using method from Java Scanner Object
                System.out.print("" + choice + ": ");
                quit = this.action(choice);  // take action
            } catch (Exception e) {
                sc.nextLine(); // error: clear buffer
                System.out.println(e + ": Not a number, try again.");
            }
        }
        sc.close();
    }

    // Print the menu options to Terminal
    private void print() {
        //System.out.println commands below is used to present a Menu to the user. 
        System.out.println("-------------------------\n");
        System.out.println("Choose from these choices");
        System.out.println("-------------------------\n");
        System.out.println("1 - Vidhi and Riya's Temp Convertor");
        System.out.println("2 - Lily's Average Calculator");
        System.out.println("3 - Vidhi's Print a Random Number");
        System.out.println("4 - Modulus Calculator");
        System.out.println("5 - F=ma calculator");
        System.out.println("0 - Quit");
        System.out.println("-------------------------\n");
    }

    // Private method to perform action and return true if action is to quit/exit
    private boolean action(int selection) {
        boolean quit = false;

        switch (selection) {  // Switch or Switch/Case is Control Flow statement and is used to evaluate the user selection
            case 0:  
                System.out.print("Goodbye! Thanks for checking this out :D");
                quit = true;
                break;
            case 1:
            Scanner input3;

            //we used a wrapper class to introduce our program to the user.
            String aString = "This is our program to convert Celcius to Kelvin. We are using it for our AP Chemistry class.";
            System.out.println(aString);
    
            //we used the string to greet the user
            input3 = new Scanner(System.in);
            System.out.println("Enter your name as a string: ");
            String name = input3.nextLine();
            System.out.println("Hello " + name );
            input3.close();
    
            //the integer is used to get the age of the user
            input3 = new Scanner(System.in);
            System.out.println("Enter your age as an integer: ");
            String age = input3.nextLine();
            System.out.println("You are " + age + " years old." );
            input3.close();
    
            //boolean is used to get a true or false answer about whether the user is in AP Chemistry
            input3 = new Scanner(System.in);
            System.out.println("Are you in AP Chemistry? Enter your answer as a Boolean: ");
            String chem = input3.nextLine();
            System.out.println("Your answer: " + chem);
            input3.close();
    
            //double is used to get a number from the user and convert it using arithmetic expression
            input3 = new Scanner(System.in);
            System.out.println("Enter a degree in Celsius as a double: ");
            double celsius = input3.nextDouble();
            double kelvin = (celsius + 273.0);
            System.out.println( celsius + " degree Celsius is equal to " + kelvin + " in Kelvin");
            input3.close();

                        break;

            case 2:
            double numDouble = 0;
            double sum = 0;
            // count = n (sample size to determine mean)
            // Sample size is always a whole number (ex: 1, 2, etc.)
            int count = 0;
            double mean = 0;
    
            Scanner sc = new Scanner(System.in);
            System.out.println("Enter numbers, type 'end' to finish");
    
            while (true) {
                // String is used as the input for each number
                // The reason why I didn't use int was because I wanted the user to 
                // be able to end the calculator by typing "end"
                System.out.println("Number: ");
                String numStr = sc.next(); 
                System.out.println(numStr);
                if ("end".equals(numStr)) {
                    break;
                }
                
                // This performs casting by changing the input, which was a string,
                // into a double so that the mean can by determined
                numDouble = Double.parseDouble(numStr);  
                sum += numDouble;
                count++;  
                
            }
            
            mean = sum/count;
    
            System.out.println("Show detailed info? y/n");
            String detail = sc.next();
            // Setting showDetail as true/false, this can be used in the future
            // as a toggle. (If showDetail = true, show more detail, otherwise,
            // only show the result)
            // Also showDetail can only be yes/no, so it can be set as a boolean
    
            System.out.println(detail);
    
            boolean showDetail;
            if ("y".equals(detail)) {
                showDetail = true;
            } else {
                showDetail = false;
            }
    
            if (showDetail) {
                System.out.println("Sum: " + sum);
                System.out.println("Count: " + count);
            }
            System.out.println("Mean: " + mean);

                    break;
            case 3:
            Scanner input5;

            System.out.println("This option will print a random number from 0 to 1");
            double random = (double) (Math.random());
            
            System.out.println(random);
                    break;
            
            case 4:
            Scanner input;

            // primitive int
            input = new Scanner(System.in);
            System.out.println("Modulus calculator");
            System.out.print("Enter your first number:");
            try {
                double mod1 = input.nextDouble();
                System.out.println(mod1);
                m1 = mod1;
            } catch (Exception e) {  // if not an integer
                System.out.println("Not an integer (form like 159), " + e);
            }
            input.close();
            
            // primitive int
            input = new Scanner(System.in);
            System.out.print("Enter the second number: ");
            try {
                double mod2 = input.nextDouble();
                System.out.println(mod2);
                m2 = mod2;
            } catch (Exception e) {  // if not an integer
                System.out.println("Not an integer (form like 159), " + e);
            }
            input.close();
    
            System.out.println("Modulus Calculator");
            double result = m1%m2;
            System.out.print(m1 + "mod" + m2 + '=' + result);
                    break;
            case 5:
            // java style to import library
// class must alway have 1st letter as uppercase, CamelCase is Java Class convention

        Scanner input2;

        // primitive int
        input2 = new Scanner(System.in);
        System.out.println("F=ma calculator");
        System.out.println("Enter the mass: ");
        try {
            double mass = input2.nextDouble();
            System.out.println(mass);
            m = mass;
        } catch (Exception e) {  // if not an integer
            System.out.println("Not an integer (form like 159), " + e);
        }
        input2.close();
        
        // primitive int
        input2 = new Scanner(System.in);
        System.out.print("Enter the accel: ");
        try {
            double accel = input2.nextDouble();
            System.out.println(accel);
            ac = accel;
        } catch (Exception e) {  // if not an integer
            System.out.println("Not an integer (form like 159), " + e);
        }
        input2.close();

        System.out.println("Force calculator");
        double Force = m * ac;
        System.out.print(m + "*" + ac + '=' + Force);

    




                break;
                    
            default:
                //Prints error message from console
                System.out.print("Unexpected choice, try again.");
        }
        System.out.println(DEFAULT);  // make sure to reset color and provide new line
        return quit;
    }

    // Static driver/tester method
    static public void main(String[] args)  {  
        new Menu(); // starting Menu object
    }

}
Menu.main(null);
-------------------------

Choose from these choices
-------------------------

1 - Vidhi and Riya's Temp Convertor
2 - Lily's Average Calculator
2 - Vidhi's Print a Random Number
4 - Modulus Calculator
5 - F=ma calculator
0 - Quit
-------------------------

1: This is our program to convert Celcius to Kelvin. We are using it for our AP Chemistry class.
Enter your name as a string: 
Hello Vidhi
Enter your age as an integer: 
You are 16 years old.
Are you in AP Chemistry? Enter your answer as a Boolean: 
Your answer: True
Enter a degree in Celsius as a double: 
30.0 degree Celsius is equal to 303.0 in Kelvin

2: Enter numbers, type 'end' to finish
Number: 
30
Number: 
45
Number: 
20
Number: 
15
Number: 
end
Show detailed info? y/n
y
Sum: 110.0
Count: 4
Mean: 27.5

3: This option will print a random number from 0 to 1
0.49700525609712976

4: Modulus calculator
Enter your first number:78.0
Enter the second number: 90.0
Modulus Calculator
78.0mod90.0=78.0
5: F=ma calculator
Enter the mass: 
60.0
Enter the accel: 73.0
Force calculator
60.0*73.0=4380.0
0: Goodbye! Thanks for checking this out :D