10/15/2012

BCS2233 OOP TEST 1 TRIAL

 latihan individu - tak perlu hantar
Chapter 1
1.1     Define hardware and software.
1.2     Define machine language, assembly language, and high-level programming language.
1.3     What is an operating system?
  
1.4     What is a comment? What is the syntax for a comment in Java? Is the comment ignored by the compiler?
   
1.5     Identify and fix the errors in the following code:

1 public class Welcome {
2   public void Main(String[] args) {
3     System.out.println('Welcome to Java!);
4   }
5 }

    
Chapter 2                                                                   

  2.1 Which of the following are invalid identifiers, why?



a)      one

b)      hello

c)       my Window

d)      JAVA

e)      1234

f)       hello,there

g)      acct122

h)      DecafeLattePlease



2.2   Write an "Evaluation Tree" for the  following expressions:



a)      3 + 5 / 7

b)      3 * 3 + 3 % 2

c)       3 + 2 / 5 + -2 * 4

d)      2 * (1 + -(3/4) / 2) * (2 - 6 % 3)



2.3 Write an algorithm (flowchart or pseudocode) for the following problem:-



(Converting Fahrenheit to Celsius) Write a program that reads a Fahrenheit degree in double from an input dialog box, then converts it to Celsius and displays the result in a message dialog box. The formula for the conversion is as follows:

celsius = (5/9) * (fahrenheit - 32)



Chapter 3



3.1 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);

 

3.2 Write an algorithm (flowchart or pseudocode) for the following problem:-
 (Computing the perimeter of a triangle) Write a program that reads three edges for a triangle and computes the perimeter if the input is valid. Otherwise, display that the input is invalid. The input is valid if the sum of any two edges is greater than the third edge. 

No comments:

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