Showing posts with label OOP. Show all posts
Showing posts with label OOP. Show all posts

Saturday, January 8, 2011

IT311 OOP SampleFrame Example

//SampleFrame.java


package sampleframe;
import javax.swing.*;
/**
*
* @author Mark Van Buladaco
*/
public class SampleFrame extends JFrame {
JPanel p1=new JPanel();
JButton b1=new JButton("Ok");
JButton b2=new JButton("Clear");
JLabel lab1=new JLabel("Contact Name");
JLabel lab2=new JLabel("Contact Number");
JLabel lab3=new JLabel("Address");
JTextField tf1=new JTextField(7);
JTextField tf2=new JTextField(7);
JTextField tf3=new JTextField(7);
public SampleFrame(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
p1.add(lab1);
p1.add(tf1);
p1.add(lab2);
p1.add(tf2);
p1.add(lab3);
p1.add(tf3);
p1.add(b1);
p1.add(b2);
add(p1);
}

}

//Main.java

package sampleframe;

/**
*
* @author Mark Van M. Buladaco
*/
public class Main {

public static void main(String[] args) {
SampleFrame sf=new SampleFrame();
sf.setTitle("Phonebook");
sf.setSize(200,250);
sf.setVisible(true);


}

}

Read more...

Wednesday, January 5, 2011

IT5 OOP Lab Exercise: ARRAYS

Use a one-dimensional array to solve the following problem: A company pays its salespeople on a commission basis. The salespeople receive $200 per week, plus 9% of their gross sales for that week. For example, a salesperson who grosses $5000 in sales in a week receives $200 plus 9% of $5000, or a total of $650. Write a program (using an array of counters) that determines how many of the salespeople earned salaries in each of the following ranges (assume that each salesperson’s salary is truncated to an integer amount):
a) $200–$299
b) $300–$399
c) $400–$499
d) $500–$599
e) $600–$699
f) $700–$799
g) $800–$899
h) $900–$999
i) $1000 and over

Instruction:
  • Send the .vb file to celticguardiandancingelf@yahoo.com
  • Due: January 6, 2010 5 pm

Read more...

Monday, January 3, 2011

IT 5 OOP Arrays Lec Note

Download VB.NET Arrays Lecture notes



If it doesn't work, try this link:

http://projectarchive.comuf.com/upload/309.pdf

Read more...

Monday, December 13, 2010

IT5 OOP Prelim Lab Exam

Computers are playing an increasing role in education. Write a program that will help an elementary school student learn multiplication. Use the Next method from an object of type Random to produce two positive one-digit integers. It should display a question, such as

How much is 6 times 7?

The student should then type the answer into a TextBox. Your program should check the student’sanswer. If it is correct, display "Very good!" in a Label, then ask another multiplication question. If the answer is incorrect, display "No. Please try again." in the same Label, then let the student try the same question again until the student finally gets it right. A separate method should be used to generate each new question. This method should be called once when the program begins execution and then each time the user answers a question correctly.


Read more...

Saturday, December 11, 2010

IT311 - OOP Laboratory Exercise 5

Java Laboratory Exercise 5

Instructions:

  • Due: December 15, 2010 11:59 pm.
  • Send the class file and the main program (Household.java and TestHousehold.java)
  • Attach and email the files in celticguardiandancingelf@yahoo.com
  • Subject: Lastname__it311_labexer5

a.) Create a class named Household that includes data fields for the number of occupants and the annual income, as well as methods named setOccupants(), setIncome(), getOccupants(), and getIncome() that set and return those values respectively. Additionally, create a constructor that requires no arguments and automatically sets the occupants field to 1 and the income field to 0. Save this file as Household.java.

b.) Create a program named TestHousehold that demonstrate that each of the methods works correctly.

c.) Create an additional overloaded constructor for the Household class you created. This constructor receives an integer argument and assigns the value to the occupants field. Add any needed statement to TestHousehold to ensure that the overloaded constructor works correctly.

d.) Create a third overloaded constructor for the Household class you created. This constructor receives two arguments, the values of which are assigned to the occupants and income fields, respectively. Alter the TestHousehold program to demonstrate that each version of the constructor works properly.

Read more...

IT311 OOP Calculator Class (Modified)

Calculator.java


package calculator;
public class Calculator{
int num1;
int num2;
int num3;
String name;
public Calculator(){
num1=0;
num2=0;
}
public Calculator(int a,int b){
num1=a;
num2=b;
}
public Calculator(String n,int a, int b, int c){
name=n;
num1=a;
num2=b;
num3=c;
}
public void add(int a, int b){
System.out.println(a+b);
}
public void add(int a, int b, int c){
System.out.println(a+b+c);
}
public void sub(int a, int b){
System.out.println(a-b);
}
public void sub(String n,int a, int b){
System.out.println(n);
System.out.println(a-b);
}
}

____________________________________________________________________

TestCalculator.java

package calculator;
import java.util.*;
public class TestCalculator2 {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
Calculator c=new Calculator();
Calculator c2=new Calculator(25,20);
Calculator c3=new Calculator("Addition",10,20,30);
c.add(10,11);
c.add(10,11,12);
c.sub(10,11);
c.sub("Subtraction", 22,13);

}
}

Read more...

Wednesday, December 8, 2010

IT5 VB.NET Lecture Notes: Procedures

Download the following link:

http://projectarchive.comuf.com/upload/317.pdf

Read more...

Saturday, December 4, 2010

IT311 OOP Calculator Class files



Here is the answer to our Laboratory Exercise

Create a Calculator class that has the basic operations methods (add, subtract, multiply or divide two values). Then create a program to test the class.

Calculator.java


TestCalculator.java


Read more...

IT311 OOP Creating own class



Download lecture notes here (click the link):

Right click "Save File As" or "Save Link as"


Example

Calculator.java

TestCalculator.java

Read more...

Wednesday, December 1, 2010

IT5 Lab Exercise 3

It will be checked on December 7, 2010


The factorial method is used frequently in probability problems. The factorial of a positive integer n (written n! and pronounced “n factorial”) is equal to the product of the positive integers from 1 to n. Even for relatively small values of n, the factorial method yields extremely large numbers. For instance, when n is 13, n! is 6227020800—a number too large to be represented with data type Integer (a 32-bit integer value). To calculate the factorials of large values of n, data type Long (a 64-bit integer value) must be used. Write a program that evaluates the factorials of the integers from 1 to 20 using data type Long. Display the results in a two column output table. [Hint: create a Windows application, use Labels as the columns and the vbCrLf constant to line up the rows.] The first column should display the n values (1–20). The second column should display n!.

Read more...

Tuesday, November 23, 2010

IT5 OOP Lecture Notes

Holycross IT5 OOP (VB.NET)
Download lecture notes on the following links

Quiz 1: December 2, 2010

Read more...

Saturday, November 20, 2010

IT311 - OOP Laboratory Exercise

Problem: Sorted Words

Background: What background? Seemed like a good idea at the time...
Input: Anyway, you're to write a program that reads in a whole bunch of words (each word is no more than 20 characters). For our purposes, words are to be separated by spaces, commas (,), !, ?, and periods (.). No word goes past the end of a line. All comparisons should ignore case.
Output: Output the sorted words, one per line, in lower case.
Sample Input:
How much wood would a woodchuck chuck if a woodchuck could chuck wood? Well? What
do you think? Are you feeling well?

Sample Console:
a
a
are
chuck
chuck
could
do
feeling
how
if
much
think
well
well
what
wood
wood
woodchuck
woodchuck
would

Sample code:

Read more...

Wednesday, November 17, 2010

IT5 - OOP (VB .Net) Lab Exer 1 and 2

Lab Exer 1
1. Develop a program that determines if a department store customer has exceeded the credit limit on a charge account. For each customer, the following facts are available:
a) Account number
b) Balance at the beginning of the month
c) Total of all items charged by this customer this month
d) Total of all credits applied to this customer's account this month
e) Allowed credit limit
The program should input as Integers each of these facts, calculate the new balance
( = beginning balance + charges – credits)
display the new balance and determine if the new balance
exceeds the customer's credit limit. For those customers whose credit limit is exceeded, the program
should display the message, “Credit limit exceeded.”

Lab Exer 2

2.A palindrome is a number or a text phrase that reads the same backwards as forwards. For example, each of the following five- digit Integers are palindromes: 12321, 55555, 45554 and
11611. Write an application that reads in a five-digit Integer and determines whether it is a palindrome.
[Hint: Check if 1st digit equals 5th, 2nd digit equals 4th.]

Read more...

Saturday, November 13, 2010

IT311 - OOP Examples (String)

Download the examples (String Class) in the following links:

Read more...

IT311 OOP Comprehensive Quiz (Strings)

Download the quiz here

If it doesn't work, follow this url: www.projectarchive.comuf.com/upload/299.doc

Write your answers in a 1/2 sheet of yellow paper

Read more...

Friday, November 12, 2010

IT311 - OOP Lecture 1 and Lecture 2

Lecture 1: Introduction to Object-Oriented Programming

Download the link here.
If it doesn't work, follow this link: www.projectarchive.comuf.com/upload/298.ppt

Lecture 2: String Class
Download the link here
If it doesn't work, follow this link: Strings Powerpoint - The String Class

Read more...
Web Marketingdrive recovery software