google.com/reader
Describe five of the blogs you picked on your blog.
Monday, June 29, 2009
Probability
What's the probability of rolling a 2 at least twice out of three rolls?
The die has 6 sides and you'll have to show me how you figured it out. (Extra point on your next test if you show me on Wednesday.)
The die has 6 sides and you'll have to show me how you figured it out. (Extra point on your next test if you show me on Wednesday.)
Wednesday, June 24, 2009
Minor Project
//Computer Inventory
//Keep track of five things. Get the info from the user (console or gui).
//Write the data about the computer inventory to a file!
//Keep track of five things. Get the info from the user (console or gui).
//Write the data about the computer inventory to a file!
Monday, June 22, 2009
Please comment on this article on your blog
Read this article and comment on your own blog. Do you agree with the author's sentiments?
Major Assignment 3 due June 28, 2009
From 10.6
Create a GUI to add workers, hours and determine their salary.
Write a superclass Worker and subclasses HourlyWorker and SalariedWorker. Every worker has a name and a salary rate. Write a method computePay(int hours) that computes the weekly pay for every worker. An hourly worker gets paid the hourly wage for the actual number of hours worked, if hours is at most 40. If the hourly worker worked more than 40 hours, the excess is paid at time and a half. The salaried worker gets paid the hourly wage for 40 hours, no matter what the actual number of hours is. Supply a test program that uses polymorphism to test these classes and methods.
Also use the following class as your tester class: /**
This class tests class Worker and its subclasses.
*/
public class WorkerTester
{
public static void main(String[] args)
{
Worker s = new SalariedWorker(''Sally'', 40);
Worker h = new HourlyWorker(''Harry'', 40);
System.out.println(s.computePay(30));
System.out.println(''Expected: 1600'');
System.out.println(h.computePay(30));
System.out.println(''Expected: 1200'');
System.out.println(s.computePay(50));
System.out.println(''Expected: 1600'');
System.out.println(h.computePay(50));
System.out.println(''Expected: 2200'');
}
}
Create a GUI to add workers, hours and determine their salary.
Write a superclass Worker and subclasses HourlyWorker and SalariedWorker. Every worker has a name and a salary rate. Write a method computePay(int hours) that computes the weekly pay for every worker. An hourly worker gets paid the hourly wage for the actual number of hours worked, if hours is at most 40. If the hourly worker worked more than 40 hours, the excess is paid at time and a half. The salaried worker gets paid the hourly wage for 40 hours, no matter what the actual number of hours is. Supply a test program that uses polymorphism to test these classes and methods.
Also use the following class as your tester class: /**
This class tests class Worker and its subclasses.
*/
public class WorkerTester
{
public static void main(String[] args)
{
Worker s = new SalariedWorker(''Sally'', 40);
Worker h = new HourlyWorker(''Harry'', 40);
System.out.println(s.computePay(30));
System.out.println(''Expected: 1600'');
System.out.println(h.computePay(30));
System.out.println(''Expected: 1200'');
System.out.println(s.computePay(50));
System.out.println(''Expected: 1600'');
System.out.println(h.computePay(50));
System.out.println(''Expected: 2200'');
}
}
Saturday, June 20, 2009
Solutions to second Project Euler
long* fib = new long[3];
fib[0] = 1;
fib[1] = 2;
long total = 0;
while(true) {
fib[2] = fib[0]+fib[1];
fib[0] = fib[1];
fib[1] = fib[2];
if(fib[2]>=1000000)
break;
if(fib[2]%2==0)
total+=fib[2];
}
System.out.println(total);
------
Another solution:
public class Problem2 {
public static void main(String[] args) {
int fib1 = 0;
int fib2 = 0;
int curFib = 1;
int sum = 0;
while(curFib < 1000000){
if(curFib % 2 == 0){
sum += curFib;
}
fib1 = fib2;
fib2 = curFib;
curFib = fib1 + fib2;
}
System.out.println("Solution to problem 2 = " + sum);
}
}
fib[0] = 1;
fib[1] = 2;
long total = 0;
while(true) {
fib[2] = fib[0]+fib[1];
fib[0] = fib[1];
fib[1] = fib[2];
if(fib[2]>=1000000)
break;
if(fib[2]%2==0)
total+=fib[2];
}
System.out.println(total);
------
Another solution:
public class Problem2 {
public static void main(String[] args) {
int fib1 = 0;
int fib2 = 0;
int curFib = 1;
int sum = 0;
while(curFib < 1000000){
if(curFib % 2 == 0){
sum += curFib;
}
fib1 = fib2;
fib2 = curFib;
curFib = fib1 + fib2;
}
System.out.println("Solution to problem 2 = " + sum);
}
}
Wednesday, June 17, 2009
Monday, June 15, 2009
Real Estate GUI
With another person (or two, or by yourself), I would like you to create three classes for a Real Estate Business. The first will be a property class with an address, price, and area. The Residential class and Commercial class will be the subclasses of the Property class. Add two attributes to each subclass.
---
Create a GUI to enter the information about the Residential or Commercial properties. Store them in an ArrayList.
Have the ability to output the ArrayList to the console.
---
Create a GUI to enter the information about the Residential or Commercial properties. Store them in an ArrayList.
Have the ability to output the ArrayList to the console.
Sunday, June 14, 2009
Wednesday, June 10, 2009
Coding this weekend.
If anyone wants to review Java, I'll be available this Saturday at 1:00 pm in room 2128 at the Kendall Campus.
Hospital Project
You will be doing a "minor project" with another classmate.
We will write software using Java for a hospital to track its patients. You will first make a Patient class and four necessary methods for the Patient. Create two possible constructors for your Patient class.
Use the Patient class to create a CriticalCare patient (Remember: extends). Add an extra method that a CriticalCare patient may need to have. Create a constructor for the CriticalCare patient.
Lastly create a Hospital class that has an ArrayList of Patients and CriticalCare patients.
Use a loop to ask a user to input the information to admit a Patient and a CriticalCare patient.
We will write software using Java for a hospital to track its patients. You will first make a Patient class and four necessary methods for the Patient. Create two possible constructors for your Patient class.
Use the Patient class to create a CriticalCare patient (Remember: extends). Add an extra method that a CriticalCare patient may need to have. Create a constructor for the CriticalCare patient.
Lastly create a Hospital class that has an ArrayList of Patients and CriticalCare patients.
Use a loop to ask a user to input the information to admit a Patient and a CriticalCare patient.
Monday, June 8, 2009
Fun assignment to end the day with !
Add all the natural numbers below one thousand that are multiples of 3 or 5.
Saturday, June 6, 2009
What do you think of this?
http://makinggoodsoftware.com/2009/06/04/10-commandments-for-creating-good-code/
Please comment on your blog.
Please comment on your blog.
Wednesday, June 3, 2009
Major Assignment 2
There is better formatting here.
P7.3
The following two programs comes from Chapter 7 in your textbook. Due Monday June 16th, 2009. Please upload both as one project and make sure to zip it before using freerschool.com. P7.2 Implement a class Purse. A purse contains a collection of coins. For simplicity, we will only store the coin names in an ArrayList void addCoin(String coinName)Add a method toString to the Purse class that prints the coins in the purse in the format Purse[Quarter,Dime,Nickel,Dime]Use the following class in your solution: import java.util.ArrayList; Use the following class as your tester class: /** | ||
P7.3
Write a method reverse that reverses the sequence of coins in a purse. Use the toString method of the preceding assignment to test your code. For example, if reverse is called with a purse Purse[Quarter,Dime,Nickel,Dime]then the purse is changed to Purse[Dime,Nickel,Dime,Quarter]Use the following class in your solution: import java.util.ArrayList; Use the following class as your tester class: /** |
On your blog...
Define the following terms:
- Interface
- Polymorphism
- Inner class
What are they used for? Where did you find good information about the terms?
Tuesday, June 2, 2009
Subscribe to:
Posts (Atom)