8/31/2010

BCS2234 Quiz 2


QUIZ 2

Object-oriented programming (OOP) is a programming paradigm that uses "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction, encapsulation, modularity, polymorphism, and inheritance.
Define the following terms:-

1. Paradigm
2. Objects
3. Methods
4. data abstraction
5. encapsulation
6. modularity,
7. polymorphism,
8. inheritance

BCS2234 01/9/ 2010 Lab ARRAYS (no 2)


1. Write a program that reads ten numbers, computes their average, and determines how many scores are above or equal to the average and how many scores are below the average.

2. Write a program that reads in ten numbers and displays distinct numbers (i.e., if a number appears multiple times, it is displayed only once). Hint: Read a number and store it to an array if it is new. If the number is already in the array, discard it. After the input, the array contains the distinct numbers. (Liang, Chapter 6 Arrays -Programming Exercise 6.5)

Related post BCS2234 30/8/ 2010 Lab ARRAYS

8/29/2010

BCS2234 30/8/ 2010 Lab ARRAYS


Review Questions (Chapter 6 ARRAYS)

Section 6.2 Array Basics

6.3 ...What is the printout of the following code?
int x = 30;
int[] numbers = new int[x];
x = 60;
System.out.println("x is " + x);
System.out.println("The size of numbers is " + numbers.length);


6.9 Identify and fix the errors in the following code:

 1 public class Test {
2 public static void main(String[] args) {
3 double[100] r;
4
5 for (int i = 0; i < class="docEmphStrong">100;
7 }
8 }

Programming Exercises

Section 6.2 Array Basics (Liang)

6.1 Write a program that reads ten numbers, computes their average, and finds out how many numbers are above the average.

6.3 Write a program that reads ten integers and displays them in the reverse of the order in which they were read.

Solution

Question 6.1
/**
* @(#)lab30_ogos_10.java
*
* lab30_ogos_10 application
*
* @author
* @version 1.00 2010/8/30
*/
import javax.swing.JOptionPane;
public class lab30_ogos_10 {

public static void main(String[] args) {

int[] r = new int[10];

// read 10 integers
for (int i = 0; i < r.length; i++)
{

String intString = JOptionPane.showInputDialog("Enter integer ");

r[i] = Integer.parseInt(intString);

}

// print out the 10 integers
for (int i = 0; i < r.length; i++)
{

System.out.println(r[i]);
}

// find average of 10 integers
int sum=0;
double average;
for (int i = 0; i < r.length; i++)
{
sum = sum + r[i];

}
average = sum/10.0;
System.out.println("Average of 10 integers = " +average);



// count the numbers that are above of average
int above_average =0;
for (int i = 0; i < r.length; i++)
{
if(average > r[i])
above_average++;

}
System.out.println("There are = " +above_average +" numbers that are above of average");
}

}

BCS2143 Nota CFG

Nota bagi CFG boleh di dapati dari link ini.

8/28/2010

Alam Persekolahan - Nasyid

Di bawah adalah lirik lagu Alam Persekolahan dari kumpulan Nirwana. Nirwana pada asalnya adalah kumpulan nasyid dari SMKH (Sekolah Menengah Agama Khairiah). Lagu ini muncul sekitar 1996 semasa saya belajar di UTM. Lagu yang bertemakan ilmu ini saya tujukan kepada para pelajar saya di TATiUC. Sila dengarkan lagu tersebut dari pautan berikut ; 1) youtube 2) 4shared


Tajuk Lagu : Alam Persekolahan
Album : G.E.N.E.R.A.T.I.O.N.S
Munsyid : Mirwana

Allah Oh Tuhan ::Pencipta Alam::Kupohon dari-Mu ::Berdoa pada-Mu

Allah Oh Tuhan ::Terangilah hatiku::Agar ku mampu ::Terus maju

Alam ::Persekolahan::Penuh dengan ::Cabaran

Perlukan ::Kesabaran::Keteguhan iman::Oh Tuhan

Kumahu ::Menimba ilmu::Agar kumampu :: Majukan ummahku

::Berusaha perlu ::Sedaya yang mampu::Dan berserah pada-Mu ::Allah Yang Satu

::Menuntut ilmu ::Bersabar selalu::Kulengkapkan diriku::Dengan azam baru

Song by Yasin
Lyris by Yasin
Produced by Syah & Yasin
Vocal by Hafiq Tarmizi

8/24/2010

BCS2234 25/8/ 2010 Lab








1. (
Conversions between Celsius and Fahrenheit) Write a class
that contains the following method:
/** Converts from Celsius to Fahrenheit */
public static double celsiusToFahrenheit(double celsius)

The formula for the conversion is:

fahrenheit = (9.0 / 5) * celsius + 32

Write a test program that invokes these methods to display the following tables:

Celsius    Fahrenheit    
40.0 105.0


2. (Conversions between feet and meters) Write a class that
contains the following method:
/** Converts from feet to meters */
public static double footToMeter(double foot)

The formula for the conversion is:
meter = 0.305 * foot

Write a test program that invokes these methods to display the following tables:

Feet    Meters    
1.0 0.305

SOLUTION (for question 1)

/**
* @(#)labChap5_Methods.java
*
* labChap5_Methods application
*
* @author
* @version 1.00 2010/8/25
*/
import javax.swing.*;
public class labChap5_Methods {

public static void main(String[] args) {

String AnsString = JOptionPane.showInputDialog ("Please Enter Celsius");
double cel =Double.parseDouble(AnsString);

double feh =celsiusToFahrenheit(cel);
System.out.println("Celcius Fahrenheit" );
System.out.println("---------------------------------");
System.out.println(cel +" " + feh);

}

public static double celsiusToFahrenheit(double celsius)
{
return ((9.0 / 5) * celsius + 32);
}

}

BCS2234 23/8/ 2010 Lab



Write method headers for the following methods:

1. Computing a sales commission, given the sales amount and the commission rate.

2. Testing whether a number is even, and returning true if it is.

3. Printing a message a specified number of times.

4. Computing the monthly payment, given the loan amount, number of years, and annual interest rate.

/**
* @(#)TestMax.java
*
* TestMax application
*
* @author
* @version 1.00 2010/8/23
*/

public class TestMax {

public static void main(String[] args) {

int i = 5;

int j = 2;

int k = max(i, j);

System.out.println("The maximum between " + i +

" and " + j + " is " + k);


System.out.println(comm(100,20)); // question 1
System.out.println(TestEven(5));// question 2
System.out.println(MP(43000,7,3.88)); // question 4

}

/** Return the max between two numbers */

public static int max(int num1, int num2) {

int result;



if (num1 > num2)

result = num1;

else

result = num2;



return result;

}

/** Comm -Return commission of a given amount sales and % commission rate */

public static double comm(double amount,double cr)
{
return (amount * cr/100);
}



public static boolean TestEven(int N)
{

if((N%2)==0)
return true;
else
return false;
}



public static double MP(double loan, int year, double IR)
{
double Total_interest_rate = year*IR;
double Total_Payment = (loan * Total_interest_rate /100)+ loan;
return Total_Payment /year/12;
}


}

8/11/2010

Salam Ramadhan 1431


Salam Ramadhan 1431 saya ucapkan kepada warga TATiUC, khususnya pepada para pelajar yang mengambil subjek OOP, TCS, C++ dan Projek. Alhamdulillah kita bertemu lagi di bulan yang membebaskan diri kita dari rutin kebiasaan masing-masing.



Perubahan
Dalam bulan ini, kita berpeluang untuk melakukan perkara-perkara yang sebelum ini kita segan lakukan,misalnya untuk jejakkan kaki ke surau TATI mungkin takut di katakan 'pak lebai' oleh member. Ramadhan adalah pendorong yang kuat, maka sama-sama kita ambil peluang.



Motivasi
Motivasi yang mendorong pelajar dalam mempelajari subjek-subjek yang di ambil adalah bagi menambah ilmu, juga untuk mendapat gred A. Motivasi dalam menambah amal-ibadat di bulan puasa juga perlu di cari. Bacalah tentang kelebihan bulan ramadhan, agar menambahkan rasa kebesaran ramadhan,insyaAllah.




Bersahur
Mengantuk adalah antara sebab ramai di antara kita yang tidak bersahur. Sedap tidur juga mungkin juga alasan. Berapa lamahkan sedap tidur itu kita rasanya semsa tidur? Bila bangun sahur, berapa lamakah rasa mengantuk itu dirasa? Ambillah kelebihan sahur seperti yang di terangkan dalam hadis dibawah.

Ibnu Umar(ra) meriwayatkan bahawa Rasulullah (saw) bersabda: "Sesungguhnya Allah dan para malaikat-Nya mengirim rahmat ke atas mereka yang makan sahur. "


Amaran
Moga kita bukanlah tergolong dari mereka yang dinyatakan dalam hadis di bawah:

Yang bermaksud : “Betapa ramai orang yang berpuasa tidak mendapat apa-apa daripada puasanya kecuali lapar dan betapa ramai orang yang berqiyam tidak mendapat apa-apa daripada qiyamnya kecuali hanya berjaga malam..” – Riwayat Ibnu Majah

Berbuka
Bulan puasa boleh menjadikan perbelanjaan harian kita lebih jimat berbanding bulan-bulan yang lain. Kerana kita hanya makan 2 kali sehari. Namun, jika kita menyajikan masa makan 2 kali sehari itu dengan makanan yang melimpah ruah sehingga terpaksa dibuang sebahagiannya- maka perbelanjaan kita pada bulan ramadhan akan jadi lebih dari bulan yang lain.
Jadual berbuka puasa bagi bagi semua daerah di Malaysia boleh di dapati dari link ini.

8/08/2010

BCS2234 Assignment 1

You are required to provide (i) Algorithm (Flowchart or Pseudocode) and (ii) Java program for each of the following problems.

1. Develop a program to input height and length of a right triangle and calculate and print the area of a right triangle.

Area of right triangle = (height x length) /2

1.1 Algorithm

1.2 Java Program

2. Write a program that prompts for and read your age in years and output your ages in days. You may assume that there are 365 days in a year.

2.1 Algorithm

2.2 Java Program

3.. Write a program that input a grade. If the grade is less than 0 or greater than 100, your program should print the appropriate message informing the user that an invalid grade has been entered.

3.1 Algorithm

3.2 Java Program

4. Write a program that read an integer from the user and determines and print whether it is odd or even (Hint: Use modulus operator)

4.1 Algorithm

4.2 Java Program

5. Write a program that input ten (10) integers. Print out the sum of those integers.

5.1 Algorithm

5.2 Java Program

8/04/2010

BCS2234 4/8/ 2010 Lab

Lab Activities 4 august 2010

Write a Java program to read a password. If the password equals to 1234 then print out “Your password is accepted”. Otherwise print “Your password is Not Accepted”.

Flowchart


Java Program
/**
* @(#)Lab3_1.java
*
* Lab3_1 application
*
* @author
* @version 1.00 2010/8/4
*/
import javax.swing.*;
public class Lab3_1 {

public static void main(String[] args) {

// TODO, add your application code
int password;
String answerString = JOptionPane.showInputDialog ("Please enter your password");
password = Integer.parseInt(answerString);
if(password == 1234)
JOptionPane.showMessageDialog(null,"Your Password is Accepted" );
else
JOptionPane.showMessageDialog(null,"Your Password is NOT Accepted" );
}
}

8/01/2010

BCT1113 LAB 1 OGOS 2010

Draw a flowchart which inputs 3 numbers, and outputs their sum, product and average.



// coding C++ tidak dapat di paparkan dengan betul di sini kerana ada beberapa simbol yang tidak di terima oleh html
#include
int main(void)
{

int N1,N2,N3,SUM,PRODUCT;
double AVERAGE;


cout<<" Sila Masukkan 3 nilai integer "; cin>>N1>>N2>>N3;

SUM =N1+N2+N3;
PRODUCT =N1*N2*N3;
AVERAGE =SUM/3;

// saya buang baris ni cout<<<<<" Sum (Hasil Tambah) = "<<<"\n"; cout<<" Product (Hasil Darab) = "<<<"\n"; cout<<" Average (Purata)= "<<<"\n"; return 0; }

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.  ...