2/02/2015

BCS2233 OOP 2BCNS SEM 2 14/15 LAB WEEK 2

Write a program to input 2 integers and print the average.

I. Pseudocode

1. INPUT two integers (N1,N2)
2. CALCULATE Average
 Average = (N1+N2) /2
3. OUTPUT Average

II. Flowchart




















III. Java Program


import java.util.Scanner;  //to read input from console 
public class bcnslabweek2 {
    
    public static void main(String[] args) {
   
    //declare variable
    int N1,N2;
    double AVG;
    Scanner input = new Scanner(System.in);
   
    //get input
    System.out.println("Please enter two integers ");
    N1 = input.nextInt();
    N2 = input.nextInt();
   
    //calculate average
    AVG =(N1+N2)/2.0;
   
    //print output
    System.out.println("Average = " + AVG);
   
    }
}

1/25/2015

BCS2233 OOP 2BCNS SEM 2 14/15

Object Oriented Programming Teaching Resources.


A. Course Plan
     BCS2233 Course Plan

B. Power Point Slide & Video


1. Slide Introduction to Java Programming, Y. Daniel Liang.  8E
    (Chapter 1,2,3,4,5,6,8,10,11,13)
2. Video Introduction to Java Programming, Y. Daniel Liang. 8E

C. Programming Tools

1. JDK (java development kit)
2. Editor JCreator Professional atau  Editor Eclipse 
 (free version for Jcreator can be downloaded here http://www.jcreator.org/)


D. Five Tips for learning Programming

1. Look at the Example Code
 Reading is usually about the words on the page, but learning to program is about code.

2. Don't Just Read Example Code--Run It
But when you're reading a programming tutorial (or book), it's easy to look at the sample code and say "I get it, I get it, that makes sense". Of course, you might get it, but you might not get it, and you just don't know it. There's only one way to find out--do something with that code.

3. Write your Own Code as Soon as Possible
Once you understand something about the language--or even if you're still getting your head around it--start writing sample programs that use it.

4. Learn to use Debugger
 The first step in doing so is to learn how to use a tool called a debugger, which allows you to step through your code.


5. Seek out More Sources
First, look for alternative explanations. The internet is filled with information about programming, and some explanations work better for different people;



1/24/2015

DCT1093 OOP Lab Week 8

Consider the following flowchart. Can you find any selection or repetition structures?




1/05/2015

DCT 1093 OOP : Pre Test 1

1.  Response to the following statements by circling either T (TRUE) or F (FALSE). [10M]

        I.            i)Without programs, a computer is an empty machine. ( T / F )
      II.          ii)  Java is NOT a high-level language. ( T / F )
    III.            iii)Java enables users to develop and deploy applications on the Internet for servers, desktop computers, and small hand-held devices.( T / F )
    IV.          iv)  Java is one of language that support object oriented programming. ( T / F )
      V.            v)Reserved words or keywords are words that have a specific meaning to the compiler and cannot be used for other purposes in the program. ( T / F )
    VI.          vi)  The main method looks like this: ( T / F )

public static void main(String[] args) {
  // Statements;
}

 
 





  VII.           vii)An identifier is a sequence of characters that consist of letters, digits, underscores (_), and dollar signs ($).( T / F )
VIII.            viii)An identifier must start with a letter, an underscore (_), or a dollar sign ($). It cannot start with a digit. ( T / F )
    IX.          ix)  Logic Errors Produces incorrect result. ( T / F )
      X.            x) Run Time Error is an error that occurs during the execution of a program. ( T / F )

2. Match the following Statement / Name to its description. [8M]



No
Statements

Description
        I.             
x = 1;

Increment
      II.             
int x = 1;

Addition
    III.             
double radius;

Declaring Variables
    IV.             
final int SIZE = 3;

Declaring and Initializing
      V.             
+

Assignment Statements
    VI.             
*

Remainder
  VII.             
%

Multiplication
VIII.             
++

Constants

3. Give a brief explanation for the following question. [10 M]


         I.            What is debugging? [2 marks]




       II.            What is the difference between a constant and a variable? [2 marks]


     III.            Explain sequence, selection and iteration as used in programming. [6 marks]

4. Which of the following are invalid identifiers, why? [10 marks]

                     I.            my
                   II.            my#address
                 III.            my_address
                 IV.            my  address
                   V.            JAVA

5. Show an evaluation tree for the following expressions: [6 marks]


                    I.            10 + 2 - 2
                  II.            3 + 3 * 3 % 2
                III.            3 + 2 / 5 +2 * 4

6. (Computing the volume of a cylinder) Write an algorithm and a Java program that reads in the radius and length of a cylinder and computes its volume using the following formulas: [20 marks]
   Area
= radius * radius * p
  volume
= area * length


7. (Finding the largest) Write an algorithm and a java  program that two integers and find the largest. [20 marks]

1. T,F,T,T,T,T,T,T,T,T
2.



3.
4.
5.
6.
7.
Question 7
Pseudocode
-----------
1.Input two integers (N1 and N2)
2.IF N1 bigger then N2 then
   output N1
   else
   Output N2


Flowchart
---------

12/17/2014

DCT1093 OOP : Quiz 1 and Assignment 1

Quiz 1

Respond with the correct answer by marking either True “T” or False “F” for each question.
      I.        High-level languages include C, C++ and Java.                                        ( T / F )
    II.        The equation wages = rate x hours can be written in Java as:
wages = rate * hours;                                        ( T / F )
   III.        Algorithm  is a step-by-step problem-solving process.                                ( T / F )
  IV.        Comments are for the compiler, not the reader.                                         ( T / F )
    V.        There are two types of comments; Single line and multiple line.                ( T / F )
  VI.        Errors in syntax are found in compilation.                                                   ( T / F )
 VII.        Java  compiler guarantees that the program follows the rules of the language and does not guarantee that the program will run correctly.                                  ( T / F )
VIII.        Semantic rule: rules that specify which statements (instructions)
are legal.                                                                                                       ( T / F )
  IX.        Identifier (variable name) must begin with a number.                                ( T / F )
    X.        Java  is NOT case sensitive - NUMBER is the same as number.             ( T / F )
  XI.        bool type has two values: true and false.                                                     ( T / F )
 XII.        Java logical operators symbols  for NOT, AND and OR are  !, &&, ||.       ( T / F )
XIII.        Variable is a memory location whose content may change
during execution.                                                                                          ( T / F )
XIV.        All operations inside of () are evaluated last (Order of Precedence)          ( T / F )
XV.        Repetition allows you to efficiently use variables.                                       ( T / F )



[15 MARKS]





Assignment 1 

Sila download 'Assignment 1' anda di sini.

12/14/2014

BCS2233 OOP: Inheritance


Create a base class named Point consisting of x and y data members representing point coordinates. From this class, derive a class named Circle with another data member named radius. For this derived class, the x and y data members represent a circle’s centre coordinates. The member method of the Point class should consist of a constructor that set the value for x and y to 0, an area() method that return 0, and distance() method that returns the distance between two points, (x1,y1) and (x2,y2), where
Distance

Additionally, the derived class should has an overided method named area() that return’s a circle area

Area = 3.14 x radius2.

Draw UML diagram that for the class Point and class Circle.

Cara download Installer windows 10 dalam format ISO

1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan.  ...