mdinfotech.net  



Section 1

Course and Lab Introduction
  • course introduction on mdinfotech
  • expectations
  • the backup talk
  • logging in
  • H drive vs C drive vs Student_Collab Drive (SAVE EVERY PROGRAM YOU WRITE ON THE H (Host) DRIVE.)
  • saving and renaming files, creating folders
  • Printing
  • evaluation
There are 4 types of assessments used to help you learn to program:
  1. 100/80/60 Quizzes: short programming problems given at the beginning of class. They are used to assess if your programming skills are where they should be.
    • 60% - indicates your programming skills are not where they should be and will require a meeting with the teacher to discuss what you can do differently to succeed
    • 80% indicates your programming skills are close to what they should be you may need to adjust the way you approach your learning in this class
    • 100% indicates you have the correct solution and that your programming skills are where they should be.
    If you are not getting 100 on these quizzes, read How to be Successful in a Programming Class on the course home page.
  2. In-Class Exercises and Programming Exercises: small exercises that take a few minutes to a couple of periods to solve and students are encouraged to keep trying until the solution is achieved. These exercises teach individual skills.
  3. In Class Assignmentcs: You will be asked to solve a complex problem that take an entire class complete. No outside resources are allowed. It is an opportunity to apply all the individual skills you have learned to a large scale problem. Programming assignments are marked against test cases that are not provided ahead of time, and your code will also be collected and assessed for formatting, commenting and chosen algorithms.
  4. Team Projects: a large scale problem that will take about two weeks to solve, in a group. Problem complexity will try to be matched with programmer skill. Each of these projects is worth 15% of your mark.
Do Programmers Actually Need Touch Typing?
  • Test your code typing speed Typing.io.
  • Lesson: Resources
    To Install Eclipse at HOME:
    • Download Eclipse Installer, and follow the directions on the download page. You want to install the version "Eclipse for Java Developers".
    Test Hello World Useful Tool For CS 12's

    A discussion on academic integrity and the importance of learning to code without relying on AI. There is value of building a strong foundation in programming.

    Notes for Ms. Wear
    Ms. Wear will teach a lesson that covers these questions. Answer them as the lesson is taught.

    Answer the questions in a Google Classroom document
    1. Define software.
    2. What is another word for program?
    3. Why was binary a bad way for humans to enter data into a computer?
    4. What was the first improvement on binary?
    5. What was the first high-level language?
    6. List other high-level languages.
    7. Is Java a high level or low level language?
    8. All running programs are stored in ______________.
    9. What is an operating system?
    10. List 3 categories of software and an example of each.
    11. List examples of operating systems.
    12. (Video) What does I/O stand for?
    13. (Video) What is an example of input hardware?
    14. (Video) What is an example of output hardware?
    15. (Video) What is multitasking?
    16. (Video) What is memory protection?
    Resources
    Use the Scanner class to get input from the keyboard.
    This needs to be the first line in your program:
                     import java.util.Scanner;
                     
    Create an instance of the scanner class. This goes at the top of main:
                     Scanner in = new Scanner(System.in);
                     
    To get integer data, create an integer variable at the top of main and get the input after asking the user to enter a number:
                     int x = 0;
                     ⋮
                     System.out.print("Please enter a number: ");
                     x = in.nextInt();
                     
    To get numbers with decimals, create an double variable at the top of main and get the input after asking the user to enter a number:
                     double y = 0;
                     ⋮
                     System.out.print("Please enter a number: ");
                     y = in.nextDouble();
                     
    To get a string up to the next hard return, create a String variable at the top of main and get the input after asking the user to enter some text:
                     String s = "";
                     ⋮
                     System.out.print("Please enter some text: ");
                     s = in.nextLine();
                     
    nextLine() can also be used to empty the input stream of extra characters.

    Additional methods can be found at the Scanner API

    Resource: Watch Using the Scanner Class
    1. Define the problem - at this level, Ms. Wear does it for you.
    2. Understand the problem - write it out in plain English.
    3. Formulate a solution - psuedocode, flow chart, or a list of steps.
    4. Make decisions about your code - what classes do I need to import? what variables do I need?
    5. Write the program - write the Java code
    6. Test the program - if it works, wonderful! If it doesn't, debug, refactor, rewrite, retest.
    1. Write a new program that uses the Scanner class to get input from the user.
    2. First, ask the user for their score on a test. The score may include half marks or decimal values, so store it in a double .
    3. Next, ask the user for the total number of marks possible on the test. This should always be a whole number, so store it in an int.
    4. Finally, calculate the percentage and display it in the console.
    Sample Input
                      3.5
                      6
    Sample Output
                      58.33333%
                      
    Extension Activity: Print the percent to one decimal place only. Read about printf.
    1) Your First Task (Notes):

    Open your CS 11 Notes document and take notes on the following topics:

    • Arithmetic Operators (+, -, *, /, %),
    • Order of Operations (Precedence): BEDMAS and left-to-right rules,
    • Division in Java: integer division and casting (converting types).
    Resources to use:
    1. Watch Arithmetic Operators in Java.
    2. Read Arithmetic Operators.
    3. Watch Casting in Java
    2) Your Second Task (Pairs Activity):
    1. Do this with a partner.
    2. Read this code JavaMath.java.
    3. Assume the user enters 10 for the first number and 7 for the second number. Write your predictions for the program output on a sheet of paper. Use your notes and the materials below to make your predictions.
    4. When you are done, complete the program.
    5. Compare your predictions to the actual output.
    6. If any of your predictions are incorrect, figure out why or ask.
    1. Create a new program that asks the user for 3 numbers. It should support decimal values. These should be doubles.
    2. It will then display the average of the three numbers in the console.
    Sample Input
                      5.5
                      6.5
                      7.5
    Sample Output
                      6.5
                      
    The first 100/80/60 Quiz.
    There are 10 kinds of people in the world, those that understand binary and those that don't.
    Watch: Representing Numbers and Letters with Binary.
    Answer the following questions in a Google Classroom Doc document during the video:
    1. What are the two possible values of a binary digit?
    2. What is the minimum value of an 8 digit binary number in binary?
    3. What is the minimum value of an 8 digit binary number in decimal?
    4. What is the maximum value of an 8 digit binary number in binary?
    5. What is the maximum value of an 8 digit binary number in decimal?
    6. Write the numbers 0 to 7 in binary.
    7. Convert the binary number: 1101101 to decimal.
    8. What is the sum of the binary numbers 1101 + 1111?
    9. What is a bit?
    10. What is a byte?
    11. Approximately how many?
      1. 1 Kilobyte = ___________bytes
      2. 1 Megabyte = ___________ bytes
      3. 1 Gigabyte = ___________ bytes
      4. 1 Terabyte = ___________ bytes
      5. 1 Petabyte = ___________ bytes
    12. Approximately how many?
      1. 1 Terabyte = _____________ kilobytes.
      2. 1 Gigabyte = _________ Megabytes.
    13. How are integers stored in a computer? What is the first bit used for?
    14. How are decimal values (or floating point values) stored?
    15. What 7-bit code was used to store letters of the alphabet?
    16. What 8-bit code replaced it to allow for 256 characters?
    17. What is the modern code that has replaced the 8-bit code?
    18. What is the ASCII value of "A"?
    19. What is the ASCII value of "a"?


    Additional Resources:

    Use this lesson to help answer questions on Variables: Everything You Need to Know Activity.

    Lesson on:
  • What is a variable?
  • Variable Declaration and Initialization
  • How to assign values to variables including strings and chars
  • Scope
  • Ms. Wear's Slides

    Activity: Run this code.
           short largestShort = Short.MAX_VALUE;
           int largestInteger = Integer.MAX_VALUE;
           double largestDouble = Double.MAX_VALUE;
           System.out.println("The largest short value is " + largestShort);
           System.out.println("The largest integer value is " + largestInteger);
           System.out.println("The largest double value is " + largestDouble);
           
    Complete these steps:
    1. Now modify this code so that it also prints the MINIMUM values of a short, integer, and a double.
    2. short,int, and double are called Primitive Data Types. Look up 8 primitive data types in Java at w3Schools.
    3. Now add a variable of each type to your program (except boolean and char). Print the minimum and maximum values of each.
    4. For the boolean type, there are only two possible values. Add this code to your program:
            boolean isCSAwesome = true;
            System.out.println("isCSAwesome? " + isCSAwesome);
            
    5. Now assign isCSAwesome the other value it can store, and print its value as well.
    6. For the char type, any character can be assigned using single quotes. Add this code to your program:
            char myInitial = 'W';
            System.out.println("My last initial is " + myInitial);
            
    7. Now assign myInitial your first initial and print its value as well.
    8. This exercise will be used to complete some of the questions in the next lesson.
    Following the completion of this exercise you will understand:
  • Primitive Data Types,
  • the size of each type
  • and the relationship between maximum and minimum values.

  • Instructions

    1. Complete the questions below on the Google Classroom Assignment Variables: Everything You Need to Know.
    2. Use the output from In Class Exercise 3, the in class lesson on variables, and the links below to complete the questions.
    3. Links to read
      1) Read Variables Tutorial.
      2) Read Variable Types Tutorial.
      3) Read Character Tutorial (You'll need the ASCII Table).
      4) Read Odd's n' Sods.

    Questions to complete:

    Variable Size, Min and Max Values
    1. Complete this table:

      Data TypeSizeMinimum ValueMax Value3 Example Values
      int4 bytes (32 bits)-31, 2, 100324333
      short
      long
      byte
      char
      boolean
      double
      float

    2. What is the relationship between the size of an integer data type and it's minimum and maximum values?
    3. List all the variable types considered to be integer types (there are 5)?
    4. List all the variable types considered to be floating types (there are 2)?
    Variable Names
    1. List all the syntax rules for naming variables:
    2. List all the conventions for naming variables:
    3. For each of the following variable names list if it is valid or invalid and explain why?
      Variable NameValid/InvalidWhy?
      num
      num1
      1num
      $num
      num 1
      num_1
      Num
      numberOne
      numberone
    4. This style of naming a variable: firstNumber, where the second word has a capital letter, is called _________________.
    5. If a variable is not named with the notation described in the previous question, will the program compile?
    Other Stuff to Know
    1. Define: scope.
    2. When assigning a variable with type char a value, what symbols must go around the value?
    3. What is the output of the following code?
      System.out.println("The Answer to the Ultimate Question of Life, the Universe, and Everything is " + 21 + 21);
      
    4. What is the output of the following code?
      System.out.println("The Answer to the Ultimate Question of Life, the Universe, and Everything is " + (21 + 21));
      
    5. Why is there a difference between the output of the above two code segments?
    6. In Java, = is not called the "equals sign", what is it called?
    7. How do you make a single line comment?
    8. How do you make a multi-line comment?
    1. Watch Data Types: char
    2. Read Java Int to Char conversion
    Do this Pairs Programming exercise (two people, one computer)
    1. Examine the Ascii Table. This shows the numerical representation of each character. For example, 'N' is stored as 78.
    2. Copy and paste the code below into a new Eclipse project named Chars And Casting. Read the program comments and make the required modifications.
      
              char c1 = 'A';
              System.out.println("The character " + c1 + " is stored as int " + (int)c1);
              System.out.println("----------------");
              // add additional code that also prints the integer values for 'a', 'z', '!', '0', '9', and '@'
              // compare these integer values to the ascii table
      
      
      
              // Explain the output of the following code
              System.out.println(c1);
              c1++;
              System.out.println(c1);
              c1++;
              System.out.println(c1);
              System.out.println("----------------");
      
              // Explain the output of the following code
              int x = 1200;
              System.out.println(x + " " + (x+1) + " " + (x+2) + " " + (x+3));
              System.out.println((char)x + " " + (char)(x+1) + " " + (char)(x+2) + " " + (char)(x+3));
      
              // Copy and paste the above code, but change the value of x to 0, 100, 200, 300, 400, 500, 600, etc
              // How high can x go before you start getting invalid characters?
      
      
         
      
                 
    3. Know: integer values of "A", "a", and "0" (zero). These will be quizzed on.
    4. Add to your CS 11 Notes: Everything you learned in this exercise, including that char is considered an integer type (like byte, short, long and int) and the definition of casting.
    Reminder to Ms. Wear: print the worksheet in part 2

    Learn about Classes and the Math Class

    Watch these videos:
    1. Classes Part 1 (9 min)
    2. Math Class (12 min)

    Learn to Read Code and Predict Output

    Do this Pairs exercise (two people, one computer)
    1. Get the worksheet printed by Ms. Wear.
    2. Complete step 1 on the Classes and JavaAPI Worksheet by reading the code in MathClassSampler.java. Try to understand the code. Write your predicted output on the worksheet.
    3. Complete step 2 on the worksheet by running MathClassSampler.java in Eclipse. Mark your answers correct or incorrect. On your worksheet, put a next to each correct prediction and an ❌ next to any incorrect prediction.
    4. Complete step 3 on the worksheet. If you are incorrect on any predictions, figure out why. On the worksheet, write down why you made an incorrect prediction, and write down the correct answer.
    5. Hand the worksheet into Ms. Wear

    Code using the Math Class

    Do this Pairs Programming exercise (two people, one computer)
    1. Read the Math API to find the methods you need to complete the following task.
    2. Modify MathClassSampler.java by adding the following functionality:
      1. Calculate sin and cos of the same number as tan and print all 3 values with descriptive output.
      2. Calculate min of the same numbers as max and print both values with descriptive output.
      3. Calculate round of the same number as square root and print both values with descriptive output. Find the rounded value of the number entered by the user, not the rounded value of the square root.
    3. Ensure both parnters have a copy of your solution to this exercise.
    4. Get Ms. Wear to mark your exercise
    Tell Ms Wear to give the Computer Science 11 Software, Programming Languages, Bits/Bytes, Arithmetic, and Variables Quiz

    String Processing is using a program to analyze the properties of a string. String processing is used extensively in programming. For example, whenever you do a Google search, the string you enter into the search field must be processed to produce the search results.

    The Java API is the online documentation for all Java classes. As a Java programmer, it is imperative you learn to use the API. In this exercise you will use the String API to process a string entered by the user.

    Learn the following:
    1. Watch the following videos:
      1. Introduction to the String Class (4 min)
      2. String Class Method: charAt (7 min)
      3. String Class Method: length (6 min)
    2. Scroll to "Method Summary" in the String API to see a list of all methods you can use to process Strings.
    3. To see an example of how to use each String method, read Using String Methods with Examples. Click on the name of the string method to see an example of how to use it.

    Create a program that uses the console to ask the user to enter a favourite quote. Analyze the quote as described below. For each item in the list you will need to use one string processing method from the String API. It is your job to read the API and determine which is the best method for the job. All output must be in the console using System.out.println().

    1. Print the letter that appears at index 10. Note: If the quote has less than 10 characters this will throw an exception.
    2. Print the index of the first occurrence of the letter t.
    3. Print the number of characters in the quote.
    4. Replace every occurrence of the word "the" with "foobar". Print the new quote.
    5. Convert the entire string to all caps. Print the new string.
    6. If the quote contains the word "horse", print "I like your taste". Hint: You will need an if statement.

    Lesson on Hardware.

    Ms. Wear's Slides

    Ms. Wear will likely post these questions a Google Classroom exercise. This material will be quizzed/tested on.

    Remember to bring a Philips screw driver. Check Classroom for the date.

    Hardware Lab
    In class notes
    • Compound Operators,
    • Increment and Decrement,
    • Precedence
    Activity - predict the output on paper, then run code to check results
    1. What is the output of this code segment?
    int a = 1;
    int b = 2;
    int c = 3;
    
    a++;
    System.out.println(a * b - c);
    c--;
    
    System.out.println(a); 
    System.out.println(b); 
    System.out.println(c);
    
    2. What is the output of this code segment?
    int a = 2;
    int b = 5;
    int c = 4;
    int d = 7;
    
    b *= 2;  
    a += d;  
    c /= a; 
    d %= b;  
    
    System.out.println(b - a * c + d);
    System.out.println(a);
    System.out.println(b);
    System.out.println(c);
    System.out.println(d);
    
    3. What is the output of this code segment?
    int x = 3;
    int y = 8;
    int z = 5;
    int w = 2;
            
    x++; 
    y--; 
          
    x *= y * 4 - 3;  
    z += w;  
    w %= x + z;  
    
    System.out.println(x + z * y - w); 
    System.out.println("x = " + x);  
    System.out.println("y = " + y); 
    System.out.println("z = " + z);  
    
    4. What is the output of this code segment?
    int i = 1;
    int j = 2;
    int k = 3;
    int m = 4;
    i += j + k;
    k = m + 5;
    j *= k;
    m /= j * 2;
    k -= m;
    System.out.println(i);
    System.out.println(j);
    System.out.println(k);
    System.out.println(m);
    
    5. What is the output? In a sentence, summarize what does this algorithm does.
    int value = 654321;
    int temp = value;
    int numD = 0;
    
    do { 
        System.out.println(temp);
        temp /= 10;
        numD++;
    } while (temp > 0);
    
    System.out.println("There are " + numD + " digits in " + value);
    			 
    Support Materials:
    1. Compound Operators
    2. Pre/Post Increment
    3. More on Pre/Post Increment
    4. Precedence
    Tell Ms Wear to give the CS 11 Variable Types, Compound Arithmetic Operators, Bytes, Hardware Quiz
    Class Discussion
    • How integers and floating point values are stored
    In Class Exercise: Round Off Error
    1. Run this program. RoundoffError.java
    2. Repeat the mathematical calculations done by the program on paper. What value do you get on paper? Does the program give the same answer?
    3. Using the links and diagram below, formulate an answer as to why the values different.
    4. Try writing a solution to the problem so the program agrees with your calculated answer.

    In your notes, summarize what Round off Error is, why it exists and how to deal with it.

    In Class Exercise: Integer Overflow
    1. Download and run MaxVariablesDemo.java
    2. Use the increment operator (++) to add one to the variables largestByte, largestShort, largestInteger, and largestLong after printing the values of each (around line 26)
    3. Immediately after increasing the value of each by one, print the values of each again.
    4. What are the new values?
    5. Using the links and diagram below, formulate an answer as to why the values are what they are.

    In your notes, summarize what Integer Overflow is, why it exists and how to deal with it.

    Resources:
    Do the self directed Number Systems Activity posted on Google Classroom.
    1. Load this code: HardwareNumbers.java into Eclipse and complete the exercise.
    2. Upon completion, you will be partnered with someone else. Assign one person even tasks, and the other person the odd tasks. The even person will explain their solutions to the even task. The odd person will explain their solutions to the odd tasks.

    1. Preparing for a Unit Exam

    • Review all resources: Go through your class notes, programming exercises, and other assignments. Focusing on key concepts, code examples, and problem-solving techniques. Highlight important topics covered in class.
    • Practice Programming: Write, debug, and run code similar to what you've learned. Use past assignments, exercises, or online problems to reinforce your understanding.
    • Understand Key Concepts: Ensure you grasp fundamental concepts such as loops, conditionals, data structures, algorithms, or other topics from the unit.
    • Study with a Buddy: Pair up with a classmate to review topics and solve problems together. Explaining concepts to others helps reinforce your knowledge.
    • Use Study Guides: Pay attention when the teacher tells you what is on the exam. Create your own study guide by summarizing key points and common questions from the unit.
    • Simulate Exam Conditions: Take a practice exam or solve problems in a quiet environment, limiting your time to mirror real exam conditions.
    • Ask Questions: Don’t hesitate to ask your teacher for clarification on topics you find challenging.

    2. Writing a Multiple-Choice Exam

    • Read All Instructions Carefully: Before starting, make sure you understand the instructions and how to record your answers.
    • Answer Easy Questions First: Quickly go through the exam and answer questions you’re confident about. This helps build momentum and saves time for harder questions.
    • Eliminate Wrong Answers: For challenging questions, eliminate obviously wrong answers to increase your chances of choosing correctly.
    • Be Mindful of Tricky Wording: Look out for words like "always," "never," or "except," as they can change the meaning of the question.
    • Check Your Work: If time allows, revisit your answers to ensure you didn’t misread questions or make careless mistakes.
    • Avoid Overthinking: Your first instinct is often correct. Only change an answer if you’re certain about the mistake.

    3. Dealing with Anxiety Before and During the Exam

    • Before the Exam:

      • Prepare Thoroughly: Confidence comes from preparation. Start studying early to avoid last-minute cramming.
      • Sleep Well: Ensure you get a good night’s sleep before the exam. A rested mind performs better.
      • Eat Smart: Have a balanced meal before the exam to keep your energy up and your mind sharp.
      • Practice Relaxation Techniques: Deep breathing or meditation can help calm pre-exam nerves.
      • Stay Positive: Replace negative thoughts with positive affirmations like, “I’ve prepared for this, and I’ll do my best.”
    • During the Exam:

      • Breathe: If you feel anxious, pause and take slow, deep breaths to calm yourself.
      • Focus on the Present: Concentrate on one question at a time instead of worrying about the entire exam.
      • Use Time Wisely: Keep an eye on the clock but don’t rush. Allocate time proportionally to the number of questions.
      • Seek Help if Stuck: If you don’t understand a question, skip it and come back later. Dwelling on one problem wastes time and increases stress.
      • Visualize Success: Picture yourself finishing the exam and feeling proud of your effort.

    By preparing well, staying focused, and managing your anxiety, you’ll set yourself up for success. Good luck!

    • All topics in this unit will be covered
    • 40 multiple choice questions
    • closed everything
    Practice Quiz