Mid Term 1 Review

Topics Covered:

Exam Policies and Rules

Make sure you've read over and understand the Assignment and Exam Policies for this course.

For Virtual Classes

For Face-to-Face Classes

For ALL Classes

Plan ahead!! Make sure you don't sleep in, as that is not a valid reason for missing a test. Make sure you leave for school earlier than normal in case you encounter transportation problems on the way (i.e traffic jam, broken-down bus, etc). If you drive, make sure you have a bus schedule - if your car won't work when you leave for school, you'll have the time and resources to take the bus, instead.

Exam Format

The exam will include the following types of questions:

Summary of Topics

The exam will cover everything you've learned to date.

This may not be a complete list. Make sure you've read the notes for each lesson, as they outline the most relevant textbook chapters.

Concepts and Theory

Coding programs in Java.

Data types and variables in Java.

Expressions, Assignment Statements, Arithmetic.

Input and Output

Selection Structure and Conditions

Practice Questions

Study Hints:


1. Using the code below...

a) Identify any syntax or logic errors in the code and suggest corrections.

b) Identify any stylistic errors or pieces of code that don't follow proper standards/conventions.

public class junk
{
public static main(String[] args) {
Scanner keys = new Scanner();
System.out.println(Enter a number:);
int somenumber = keys.next();
HalvedNumber = somenumber / 2
System.out.println("Your number doubled: " (somenumber * 2));
System.out.print("Your number halved: + halvedNumber);
}

2. What is the output of the following program?

public class Question2 {
    public static void main(String[] args) {
        int x = 2, y = 5, z = 20;
        System.out.print("even?");
        System.out.print(z%x);
        x += z / x + y++;
        System.out.println(" x is " + x);
        System.out.println(" y is " + y);
        System.out.println(" z is " + z);
        int blah = x + y * z - y;
        System.out.println("blah? " + blah + 1);
    }
}

3. a)Complete the tasks indicated in the comments:

public class SalesJunk
{
     public static void main(String[] args)
     {
        // get a sales amount from the user using a Scanner object
        // get a commission rate from the user (e.g. 5 for 5%)
        // calculate and display (on the console) the amount of commission the
        //  sales person should be paid (sales * comm) - format to 2 decimal places
     }
}

4. Write a simple application to calculate the cost of making custom vertical blinds for a window. Your program should prompt the user to enter the length and width of the window in metres, and the cost per square metre of the fabric for the blinds. Your program should calculate and display the totals and taxes on the console in the following format:

Cost of your vertical blinds:
Sub Total:   $ 100.00
HST:         $  13.00
Final Total: $ 113.00

In this example, the user inputs were 5 for the length, 10 for the width, and 2 for the cost of fabric.

5. Modify question 4: if the sub total is more than $100, apply a 10% discount to the order. Your output would appear as:

Cost of your vertical blinds:
Sub Total:   $ 120.00
Discount:    $  12.00
HST:         $  14.04
Final Total: $ 122.04

[ SOLUTIONS ]

-->