CSI 311L Lab 5, Spring 2012

American University of Science and Technology · Java Programming Laboratory · 3 pages · Dr. Saeed Raheel

All CSI 311L files
CSI 311L Lab 5, Spring 2012, page 1

Stuck on a question? A tutor can walk you through it.

CSI 311L Lab 5, Spring 2012, page 2 CSI 311L Lab 5, Spring 2012, page 3

More CSI 311L files

Show the text of this lab
American University of Science & Technology Department of Computer Science CSI 311L – Java Programming Lab Spring 2011/2012 Lab Work 5 Problem1: a-You have written the following program. What will be the output of the program after compiling and running it? public class Q2{ public static void main( String arguments[] ) { Amethod( arguments ); } public void a method( String args[] ){ System.out.println( args ); System.out.println( args[ 1 ] ); } } A. The program will fail to compile. B. Another method should be declared within the class. C. The program will compile successfully. D. main not found in the program b- Consider the following line of code: int[] x = new int[25]; After execution, which statement or statements are true? A x[24] is 0. B x[24] is undefined. C x[25] is 0. D x[0] is null. E x.length is 25 1 HELLO!!!!! Problem 2: Write an application to draw the following: Problem3: Write the class definitions and implementations for the following class specification.  A Point is defined by its x and y coordinates.  The class implementation should provide a default constructor.  Overload the constructor to initialize an object attributes to values specified by the user.  Provide set and get methods.  Provide print method. Write an application to create N distinct points. Then output a list of the points that fall in the first quadrant. 2 Problem 4 : Write the class definitions and implementations for the following class specifications. Salesperson Attributes  ID: an integer to identify each staff.  fname: a string of characters .  lname: an stringof characters .  rank: an integer to classify a staff position.(1,2,3)  BS: a double value for a staff basic salary.  Count: to count all instantiated objects. Methods  Constructor.  toString: a function, to return the information about a salesperson as follows: 4567 Imad Faraj has rank 2 and salary 800$ and 744$ after tax  Provide set and get functions.  Calculate _salary: compute a salesperson salary by deducting a tax from the basic salary depending on the rank as follows: 1. for rank 1 a tax of 5% is deducted. 2. for rank 2 a tax of 7% is deducted. 3. for rank 3 a tax of 10% is deducted Write a java application to create N objects of the class salesperson and display a menu to do the following: 1. Calculate the total salesperson salaries. 2. Display the information about the salesperson with salaries less than the average. 3. Display a sorted list with respect to salesperson names. 3