Cadangan Ujian 1 satu adalah seperti berikut:-
Tarikh: 13/11/2013 (Rabu)
Masa: 8:30 MALAM
Tempat: THRT A
Topik dan format adalah seperti berikut:-
Chapter 1
1.1 Describe the history of Java. Can Java run on any machine? What is needed to run Java on a computer?
1.2 What are the input and output of a Java compiler?
1.3 Explain the Java keywords. List any five Java keywords
1.4 Is Java case-sensitive?
1.5 What is the Java source filename extension, and what is the Java bytecode filename extension?
1.6 What is a comment? What is the syntax for a comment in Java? Is the comment ignored by the compiler?
Chapter 2
2.1 Translate the following pseudocode into Java code:
Step 1: Declare a double variable named MILES with initial value 1000;
Step 2: Declare a double constant named MILE_TO_KILOMETER with value 1.609;
Step 3: Declare a double variable named KILOMETER, multiply miles and MILE_TO_KILOMETER and assign the result to kilometer;
Step 4: Display kilometer to the console.
2.2 Identify and fix the errors in the following code:
1 public class Test {
2 public void main(string[] args) {
3 int i;
4 int k = 100.0;
5 intj = i + 1;
6
7 System.out.println("j is " + j + " and
8 k is " + k);
9 }
10 }
chapter 3
Suppose x = 3 and y = 2, show the output, if any, of the following code. What is the output if x = 3 and y = 4? What is the output if x = 2 and y = 2? Draw a flowchart of the following code:
if (x > 2) {
if (y > 2) {
int z = x + y;
System.out.println("z is " + z);
}
}
else
System.out.println("x is " + x);
Chapter 4
4.1 Convert the following for loop statement to a while loop and to a do-while loop:
long sum = 0;
for (int i = 0; i <= 1000; i++)
sum = sum + i;
Programming
Write an algorithma and java program for each of the following problems:-
1. Write a program to continuously read in integers and stop when a negative number is entered.
2. Write a program that prompts the user to enter the number of students and each student's name and score, and finally displays the student with the highest score.
10/29/2013
10/28/2013
BCS2233 OOP : LAB WEEK 8
Reduce the length of code of the following java program by adding repetition and method for a suitable parts.
import java.util.Scanner;
/**
Write a program to Compute a sales commission for a three persons, read the sales amount and the commission rate.
*/
public class method1 {
public static void main(String[] args) {
double sales_amount, commission_rate,commision;
Scanner scanner = new Scanner(System.in);
//---------------baca data pertama----------------------------
System.out.println("Sila masukkan jumlah jualan dan kadar komisen");
sales_amount = scanner.nextDouble();
commission_rate=scanner.nextDouble();
//----------------kira komisen dan cetak -----------------------
commision= (commission_rate /100) * sales_amount;
System.out.println("Komisen anda ialah RM " +commision );
//---------------baca data kedua----------------------------
System.out.println("Sila masukkan jumlah jualan dan kadar komisen");
sales_amount = scanner.nextDouble();
commission_rate=scanner.nextDouble();
//----------------kira komisen dan cetak -----------------------
commision= (commission_rate /100) * sales_amount;
System.out.println("Komisen anda ialah RM " +commision );
//---------------baca data ketiga----------------------------
System.out.println("Sila masukkan jumlah jualan dan kadar komisen");
sales_amount = scanner.nextDouble();
commission_rate=scanner.nextDouble();
//----------------kira komisen dan cetak -----------------------
commision= (commission_rate /100) * sales_amount;
System.out.println("Komisen anda ialah RM " +commision );
}
}
import java.util.Scanner;
/**
Write a program to Compute a sales commission for a three persons, read the sales amount and the commission rate.
*/
public class method1 {
public static void main(String[] args) {
double sales_amount, commission_rate,commision;
Scanner scanner = new Scanner(System.in);
//---------------baca data pertama----------------------------
System.out.println("Sila masukkan jumlah jualan dan kadar komisen");
sales_amount = scanner.nextDouble();
commission_rate=scanner.nextDouble();
//----------------kira komisen dan cetak -----------------------
commision= (commission_rate /100) * sales_amount;
System.out.println("Komisen anda ialah RM " +commision );
//---------------baca data kedua----------------------------
System.out.println("Sila masukkan jumlah jualan dan kadar komisen");
sales_amount = scanner.nextDouble();
commission_rate=scanner.nextDouble();
//----------------kira komisen dan cetak -----------------------
commision= (commission_rate /100) * sales_amount;
System.out.println("Komisen anda ialah RM " +commision );
//---------------baca data ketiga----------------------------
System.out.println("Sila masukkan jumlah jualan dan kadar komisen");
sales_amount = scanner.nextDouble();
commission_rate=scanner.nextDouble();
//----------------kira komisen dan cetak -----------------------
commision= (commission_rate /100) * sales_amount;
System.out.println("Komisen anda ialah RM " +commision );
}
}
10/23/2013
DCT1083 : Jawapan 'Assignment' 1
Berikut adalah di sertakan jawapan 'Assignment' 1 oleh pelajar 1 DCNT. Sila gunakan untuk mengulangkaji subjek Programming. Terima kasih untuk pelajar berkaitan bagi jawapannya.
10/21/2013
BCS 2233 OOP lab week 7
1. Tuliskan program java bagi flowchart berikut (sebagaimana di bincangkan dalam kelas)
2. Tuliskan program java bagi flowchart berikut (penambahan pada aobjek yang di warnakan merah dan perubahan pada objek yang di warnakan kuning.
3. Ubah flowchart supaya program akan tamat jika 3 kali 0 (kosong) di inputkan secara berturut-turut.
2. Tuliskan program java bagi flowchart berikut (penambahan pada aobjek yang di warnakan merah dan perubahan pada objek yang di warnakan kuning.
3. Ubah flowchart supaya program akan tamat jika 3 kali 0 (kosong) di inputkan secara berturut-turut.
10/19/2013
DCT1083 Lab : Revision
1. Write an algorithm and a C++ program to find the area of a right triangle. The area of the right triangle is given by the following formula.
area = 0.5 x (length x width)
2. Write a program to calculate the sum of EVEN integers starting from 1 to 10.
3. Write a program that reads ten integers and displays them in the reverse of the order in which they were read
4. Write an algorithm and a C++ progam that read 20 integers. Find the maximum among the 20..
area = 0.5 x (length x width)
2. Write a program to calculate the sum of EVEN integers starting from 1 to 10.
3. Write a program that reads ten integers and displays them in the reverse of the order in which they were read
4. Write an algorithm and a C++ progam that read 20 integers. Find the maximum among the 20..
10/06/2013
DCT1083 Programming Fundamentals : Assignment 3
ASSIGNMENT 3
1. MANAGING MEMORY
1.1 Define the following terms:-
i. Sizeof()
ii. Malloc()
iii. Calloc()
iv. Realloc()
v. Free()
1.2 Write a program fragment how you use a Malloc() and Free() an a c++ program.
2. POINTER
2.1 What is pointer ?
2.2 Why you use pointer?
2.3 What is output by the following program segment?
2.4 What is output by the following program segment?
3. FILE INPUT AND FILE OUTPUT
3.1 Write a program that reads the content of a file(oldfile.dat) as follows and write it into a new file(newfile.dat).
10/02/2013
DCT1083 PROGRAMMING FUNDAMENTLAS : LAB 3 OKT 2013
1. Write a program statement that will do the following to array MyArray shown below:
int MyArray[10];
for(i=0;i<=9;i++)
MyArray[i]=i*2;
i. Print all elements of array MyArray.
ii. Print all element of array MyArray in reverse.
iii. Print the first element.
iv. Replace the value of third elements with 7.
v. Copy the value of fifth elements into the first one.
vi. Find the sum of the first five elements
vii. Display all even-numbered elements on one line.
2 Write a program that reads ten integers and displays them in the reverse of the order in which they were read.. (Hint: Use loop with an array).
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
// TODO, add your application code
system("PAUSE");
return EXIT_SUCCESS;
}
Subscribe to:
Posts (Atom)
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. ...
-
ANSWERS TO CHAPTER EXERCISES (CHAPTER 8) Review Questions 1. List and describe various types of output, including technolog...
-
Based on real life scenario on any local company/ organization which you are very familiar, define the problem that could be addressed thr...
-
A. Response to the following statements by circling either T (TRUE) or F (FALSE). [10M] I. 1. Java enables users...