Java代写,java作业代写:100%原创代码
当前位置:以往案例 > >CS案例之JAVA GUI可视窗口Homework class
2018-06-02


WRITING PART

1. Consider the following definition of class MyClass


class MyClass
{
private String A;
private char B;
private int C;
private double D;
}

a. Create a default constructor assigning “”, ‘ ‘, 0, and 0.0 to the class variables. Hints: Read “default constructor” in your textbook.

b. Create the second constructor that has two parameters assigned to A and B.

c. Create the third constructor that has four parameters assigned to A, B, C, and D.

d. Create get methods for the class variables.

e. Create set methods for the class variables.

f. Create an object named X. In object X, initialize A to “Table” and B to ‘T’. Use the most appropriate constructor to create this object.

g. Create the second object named Y. In object Y, initialize A to “Chair”, B to ‘k’, C to 100, and D to 5.99. Use the most appropriate constructor to create this object.

h. Create the third object named Z. In object Z, initialize A to “”, B to ‘ ‘, C to 0, and D to 0.0. Use the most appropriate constructor to create this object.

i. Display the value of A in object X.

j. Display the value of C in object Z.

k. Assign ‘?’ as the new value of B in object Y.

l. Display the value of B in object Y.

m. Assign 7 as the new value of C in object X.

n. Assign 3.12 as the new value of D in object Z.

o. Display the value of C in object X.

p. Display the value of D in object Z.

2. Consider the following definition of class MyClass:


class MyClass
{
private int X;
private int Y;
public MyClass ()
{
X = 100;
Y = 200;
}
public MyClass (int A)
{
X = A;
}
public MyClass (int A , int Β)
{
X = A;
Y = B;
}
public void A ()
{
System.out.println (X);
}
public void B ()
{
System.out.println (Y);
}
public int C ()
{
Y = Y + 10;
return Y;
}
public int D ()
{
return X++;
}
}

What is the output of the following code?


public class XYZ {
public static void main(String[] args) {
MyClass K = new MyClass ();
MyClass L = new MyClass (10);
MyClass M = new MyClass (2 , 4);
K.C();
L.D();
M.C();
K.A();
K.B();
L.A();
L.B();
M.A();
M.B();
K.D();
L.C();
M.D();
K.A();
K.B();
L.A();
L.B();
M.A();
M.B();
}
}

3. Consider the following definition of class a:


class a
{
private int x;
private int y;
public a () {
x = 10;
y = 20;
}
public a (int k , int l) {
x = k;
y = l;
}
public void m () {
System.out.println (y);
}
public int n () {
return x;
}
}

What is the output of the following code?


public class abc {
public static void main(String[] args) {
a g = new a();
a h = new a(222 , 444);
g.m();
h.m();
System.out.println(g.n () + 200);
System.out.println(h.n () + 100);
}
}

PROGRAMMING PART

4. Develop a GUI application that allows the user to enter two numbers, select “Addition, Subtraction”, either “Multiplication”, or “Division”, and display the sum, the difference, the product, or the ratio of those two numbers. Use two text fields to allow the user to enter the numbers. Use radio buttons to allow the user to enter one of the four operations.

5. Develop application #4 using four buttons (+ button, – button, x button, / button) instead of radio buttons.

6. Develop a GUI application that stores student data (student ID, first name, last name, address, year, major) in a 2D array and allows the user to search for student data by student ID, first name, or last name.

Algorithm: (1) Create a 2D array storing student data by using the array below. Note: The array includes multiple records that have the same first name and/or last name. (2) Use a text field to allow the user to enter student ID, first name, or last name.  (3) Read each student ID, first name, and last name from the array and compare it to the user input. If they match, display the data for that student on a text area. Note: Allow the application to display data of several students having the same first name or last name.

Use this array:

{"01","Sam","Doe","12 Main St.", "Sophomore", "Finance"}, {"02","Kim","Doe","12 Market St.", "Junior", "Business Administration"},{"03","Debby","Summer","120 Main St.", "Senior", "Business Administration"},{"04","Bill","Winter","102 Rose St.", "Sophomore", "Accounting"},{"05","John","Kettinger","12 Pulaski St.", "Sophomore", "Computer Sciences"},{"06","Jill","Pearson","1224 Andrew St.", "Freshman", "MIS"},{"07","Ann","Williams","5 Church St.", "Senior", "MIS"},{"08","Anita","Newell","9 Main St.", "Freshman", "Marketing"},{"09","Anita","Goodyear","88 Akron St.", "Junior", "Nursing"},{"10","Mark","Summer","128 Wilmington St.", "Senior", "Accounting"},{"11","Helen","Newell","12 First St.", "Sophomore", "Finance"}, {"12","Alice","Lee","12 Patriot St.", "Junior", "Business Administration"},{"13","John","Summer","44 Market St.", "Senior", "Business Administration"},{"14","Bill","Adler","102 Hill St.", "Sophomore", "Accounting"},{"15","John","Pearson","12 Pulaski St.", "Junior", "Computer Sciences"},{"16","Ryan","Gibbs","1224 Hunter St.", "Sophomore", "MIS"},{"17","Pete","Williams","12 Church St.", "Senior", "MIS"},{"18","Susan","Newell","9 Rosemary St.", "Freshman", "Marketing"},{"19","Anita","McArthur","721 Akron St.", "Sophomore", "Nursing"},{"20","Dick","Summer","77 Corporate St.", "Senior", "Accounting"}




在线提交订单