Sie sind auf Seite 1von 3

PERBAIKAN PEMROGRAMAN KOMPUTER

1. What does the following program output? Public class DisplayMotto { Public static void main (String[] args) { System.out.println(We will not go it\nalone; } } 2. What is the output of the following code segment? Int t1 = 17; Int t2 = 3; Int t3 = 7; System.out.println(value = + ( t1 % t2 * 5 / t3 )); System.out.println(value = + ( t3 * ( -5 / 2 ) + t2 )); System.out.println(value = + ( t3 + t1 * 4 + t1 )); 3. Write a Java expression for the following mathematical expression.

a. b. c. d. ( ) (FV, PV, INT, YRS are variables) ( ) ( )

4. Write a program ReplaceTester that encodes a string by replacing all letters i with ! and all letters s with $. Use the replace method. Demonstrate that you can correctlyencode the string Mississippi. Print both the actual and expected result. 5. The intersection method computes the intersection of two rectanglesthat is, the rectangle that is formed by two overlapping rectangles:

You call this method as follows: Rectangle r3 = r1.intersection(r2); Write a program IntersectionPrinter that constructs two rectangle objects, prints them, and then prints the rectangle object that describes the intersection. Then the program should print the result of the intersection method when the rectangles do not overlap. Add a comment to your program that explains how you can tell whether the resulting rectangle is empty. 6. From figure in number 5, find the dimention (heigh, width), volume, and area of intersection. Keyword: with methods getHeight(), getWidth(), getSurfaceArea() and getVolume(). 7. Explain the differences between 2, 2.0, 2, 2, and 2.0. 8. In this project, you will perform calculations with triangles. A triangle is defined by the x- and ycoordinates of its three corner points. Your job is to compute the following properties of a given triangle: the lengths of all sides the angles at all corners the perimeter the area

Of course, you should implement a Triangle class with appropriate methods. Supply a program that prompts a user for the corner point coordinates and produces a nicely formatted table of the triangle properties.

NOTE: Silahkan dikerjakan bagi yang MAU mengerjakan. Tidak harus dikerjakan semua, tetapi apabila semua dikerjakan dengan baik dan benar, maka total poin 100 (maksimum untuk menggantikan UTS). Disarankan untuk Diketik, tidak disarankan untuk di tulis tangan, tetapi apabila terpaksa dikumpulkan dengan tulisan tangan, saya terpaksa juga menerimanya. Batas waktu pengumpulan maksimum hari Jumat pukul 17.00 di Meja saya. Jangan lupa, NAMA, ABSEN, KELAS. Terakhir, harap dikerjakan mandiri. Curang tidak ada toleransi. Semoga sukses dan diberi kemudahan.

-Setiap perbuatan curang, pasti ada balasan, Tuhan tidak tidur-

Das könnte Ihnen auch gefallen