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;
}


}

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