Aug 5, 2008

Java, java and java


Java, java and java. Why don't you give it a try. That's what we learn everyday in computer class. Salman is a good student, who always did programming fast. The same goes to Helmi, Muhammad Thaqif and Amiruddin. Among all, Ong Shang Khoon will be called if there only limited time, because Mr Hiung view him as a very good student. And, also Prasshant. Aye Thun progress better from day to day. Farah and Farihin are two malays girls, in the beginning, always been asked questions. Tey Pok Lin... No comment.

Other students - There are all great! - Anderson, Chung Nian Yi, Goh Xin Ying, Joshua, Juzer, Lim Shao Xian, Liong Siew Chek, Muzammil, Stephen, Zaw Linn Naung.
I have listed all my classmates. That's not bad.

Tomorrow is the java lab assignment. Students are to answer the question, and can refer to any resource except discussing or chatting with friends.

I have made note below for me and some who knew this blog to refer tomorrow.

Before that, let me try to recall important things:

** Use correct data types
** Use correct variables
** Use str for String
** Make the program readable
** \\Write comments (2marks)
** constant, CAPITAL_LETTER
** Class name - begin with Capital letter

[sampleCodes]

CalculateSquareRoot

import MyInput;
public class CalculateSquareRoot {
public static void main(String[] args) {

//read the integer from the user
System.out.println("Please enter an integer: ");
double num = MyInput.readDouble();

//compute the square root of this integer
double squareRoot = Math.sqrt(num);

//display the output on the screen
System.out.println("The square root of " + num + " is +/- " + squareRoot);

CalculateAreaJOptionPane

//constant
final double PI = Math.PI;

//read the radius from the user
String str = JOptionPane.showInputDialog(null, "Please enter the radius: ",
"First Radius Input",
JOptionPane.QUESTION_MESSAGE);
double radius = Double.parseDouble(str);

//compute the area of a circle
double area = Math.pow(radius,2) * PI;

//display the answer on the screen
JOptionPane.showMessageDialog(null, "The radius is " + radius + " \nThe area is: " +
area, "Area Result",
JOptionPane.INFORMATION_MESSAGE);

System.exit(0); //terminate program normally

CalculateArea

//constant
final double PI = Math.PI;

//read the radius from the user
System.out.println("Please enter the radius: ");
double radius = MyInput.readDouble();

//compute the area of a circle
double area = PI * Math.pow(radius,2);

//display the answer on the screen
System.out.println("The radius is " + radius);
System.out.println("The area is " + area);

13 comments:

  1. QUESTION 1

    Company JICM want to build few ceramic cylinder poles with various heights and diameters. The engineers of JICM will have to tabulate manually all the different volumes of these poles relative to its height and diameters. In order to ease the tedious calculation of the volumes of all the various poles, JICM plans to purchase a custom-made application for this purpose. Your company has been selected to deliver the custom-made application that will compute the volumes of any types of cylinder with regards to its heights and diameters. Since you are the head programmer, you will have to produce a complete Java application (console) that will read in the diameter and length of a cylinder and show the calculated volume as the output.


    QUESTION 2

    The ICT department of a bank were required to produce a Java application (console) that will compute the future investment value according to the investment amount, annual interest rate, and number of years. This program serves as a facility for the customers of this bank to help them to determine their future investment value and at the same time help them to decide the amount of money the customers want to deposit into the bank. This Java program will have to read the input of investment amount, annual interest rate and number of years and hence be able to compute the future investment value for the customer’s reference.

    Formula:
    futureInvestmentValue = investmentAmount x (1 + monthlyInterestRate)^ numOfYears * 12

    [question 2 is like a math question]...haha

    ReplyDelete
  2. huhu...kod ape tu?
    mcm kod moorse je..ke da vinci code..
    bikin pening la..

    ReplyDelete
  3. cm sgt cmplex.. guess xde kot dlm computing skills class ak.. huhu..

    ReplyDelete
  4. On sahabat:

    kod java la..
    aku tertinggal constant ar...//huhu..
    kurg mrkh lak...

    On layyinulharir:

    huhu...ni mmg special comp class.
    klu yg amik dent. or medic xkn nk maik kom cm ni kot...
    //system.out
    huhu...

    ReplyDelete
  5. ish ish ish..

    best arh korang ada kelas bab2 komputer ni..

    blaja java lagi..

    jelez jelez jelez...


    bila kau da belajar banyak2 lagi, makin bertambah ar karisma kau tu..

    adeyh~ lagi aku gerun kat kau..

    wawawawawa

    ReplyDelete
  6. This comment has been removed by a blog administrator.

    ReplyDelete
  7. pergh..sepatah haram xphm!!ahaha..
    aku pon berminat gak nk blaja java neh,,tp disbbkn html pon xlps2,,so,,mls la..hehe..

    ReplyDelete
  8. On aqila aini:

    sarcastic..
    karisma la apa la...
    anda seorg yg mengamalkn sarcasm..
    sungguh hambar begitu..

    ReplyDelete
  9. On izyan:

    ooohh..html xlepas ek..
    http lepas x?
    huhu...

    ReplyDelete
  10. eyh sy tak mengamalkan sarcasm ler..

    wawawawawa...

    eyh, best tak belajar java ni? ades~ teringin nak belajar..

    tapi, janji basic html lepas...

    wahahahhaaaa..

    ReplyDelete
  11. huhu..bes la...
    meyh la blaja...
    "saya tak mengamalkn sarcasm" itu ialah ayat paradoxical...
    yg mne asalnye dr sarcastic irony..
    hehe...

    ReplyDelete
  12. Snippet_Aug 7

    ** Reu is reported to be smooth

    ** Tomorrow, the quiz+test day: Advanced Function Quiz, Chemistry Quiz, and Computer & Information Science Test - Today is English test

    ** Eng 3U Test today is hell to some. Plus, some had to take the late bus

    ** Java-Java-Java - 3 non-stop assignment-quiz-test days

    ReplyDelete

Read, rethink, recomment