Example Lab 3.1
[1] Question :
(Checking whether a number is odd)
Write a program that reads an integer and checks whether it is odd.
[2] Example Code :
------------------------------------------------------------------------------------------------------------------------
// Step 1 : Prompt the input
Scanner input = new Scanner(System.in);
// Step 2 : Enter an integer
System.out.print("Enter an integer: ");
int number = input.nextInt();
// Step 3 : Selection statement + Display Result
if (___________________ )
System.out.println("_____________________________");
else
System.out.println("_____________________________");
-------------------------------------------------------------------------------------------------------------------------
[3] Answer :
--------------------------------------------------------------------------------------------------------------------------
import java.util.Scanner;
public class Lab3_1 {
public static void main(String[] args) {
// Step 1 : Prompt the input
Scanner input = new Scanner(System.in);
// Step 2 : Enter an integer
System.out.print("Enter an integer: ");
int number = input.nextInt();
// Step 3 : Selection statement + Display Result
if (number % 2 != 0 )
System.out.println("Is "+ number + " an odd number? True");
else
System.out.println("Is "+ number + " an odd number? False"); }
}
-------------------------------------------------------------------------------------------------------------------------
[4] Output :
Enter an integer: 17
Is 17 an odd number? True
Enter an integer: 500
Is 500 an odd number? false
DCT 1093 - Lab 3 - Selections (Lab 3.1)
DCT 1093 - Lab 2 - Elementary Programming
Example Lab 2.2
[1] Question :
(Converting Celsius to Fahrenheit)
Write a program that reads a Celsius degree in double from the console, then converts it to Fahrenheit and displays the result.
The formula for the conversion is as follows:
fahrenheit = (9 / 5) * celsius + 32
[2] Answer :
-------------------------------------------------------------------------------------------------------------------------
import java.util.Scanner;
public class Lab2_2 {
public static void main(String[] args) {
// Step 1 : Prompt the input
Scanner input = new Scanner(System.in);
// Step 2 : Enter a degree in Celsius
System.out.print("Enter a degree in Celsius: ");
double celsius = input.nextDouble();
// Step 3 : Calculation
double fahranheit = ((9.0/5)* celsius) + 32;
// Step 4 : Display Celsius in Fahrenheit
System.out.println( (int) celsius + " Celsius is " + fahranheit + " Fahranheit" );
}
}
--------------------------------------------------------------------------------------------------------------------------
[3] Output :
Enter a degree in Celsius: 43
43 Celsius is 109.4 Fahrenheit
DCT 1013 - Group Assignment 1
Group Assignment 1 - DCT 1013
As attached is a group assignment 1 for subject DCT1013.
------> GROUP ASSIGNMENT 1
Please check the selected key term for your group. For name labeling
with red colors, make sure your choose other key term for your group and
inform me before 15-01-2013.
DCT1013 - Introduction to IT
Introduction to IT (DCT1013)
- Lesson Plan
- Lecture Notes:
Chapter 1 - Introduction to Computer [update 2/1/2013]
Chapter 2 - The Internet and The World Wide Web [update 2/1/2013]
Chapter 3 - Computing Basics
Chapter 4 - Electronic Word Processor
Chapter 5 - Electronic Presentation
Chapter 6 - Spreadsheet
Chapter 7 - Current and Ethical Issues
- Lab Exercises :
Lab 1 - Computer System
- PART A
- PART B
Lab 2 - Internet
- PART A
Lab 3 - Operating System
- PART A
Lab 4 - Electronic Word Processor
- PART A
Lab 5 - Electronic Presentation
Lab 6 - Electronic Spreadsheet
DCT1093 - Object Oriented Programming
Object Oriented Programming (DCT1093)
- Lab Exercises :
Lab 2 - Elementary Programming [update 2/1/2013]
Lab 3 - Selections [update 2/1/2013]
Lab 4 - Loops [update 6/1/2013]
Lab 5 - Methods
Lab 6 - Objects and Classes
Lab 7 - Inheritance and Polymorphism
Lab 8 - GUI Basics and User Interface
Lab 9 - Applets
Lab 10 - Exception Handling
FCT1023 - Fundamental of Computer Organization
Fundamental of Computer Organization (FCT1023)
- Lecture Notes :
Chapter 2 - Data Representation
Chapter 3 - Digital Logic
Chapter 4 - CPU Architecture [update 30/1/13]
Chapter 5 - Memory System
Chapter 6 - Input / Output
- Tutorial :
Tutorial 2 (T2 Answer)
Tutorial 3 (T3 Answer)
Tutorial 4 [update 30/1/13]
Tutorial 5
Tutorial 6
FCT1063 - Programming II
Programming II (FCT1063)
- Additional Notes :
Flowchart
- Lecture Notes :
Chapter 2 - Selection Statements
Chapter 3 - Looping Statements [update 30/1/13]
Chapter 4 - Sequential File Processing
- Lab Exercises :
Lab 2 - Input and Output
Lab 3 - Selection Statements
Lab 4 - Looping Statements
Lab 5 - Sequential File Processing
- Software :
(http://www.bloodshed.net/dev/devcpp.html)