Joe Grimp

Greenhorn
+ Follow
since Apr 02, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Joe Grimp

Ok here is what i have to do -

I need to complete and test class SortLinkedList below which is intended to perform a mergesort on a linked list of LinearNodes referencing Comparable objects, by providing code to:

Complete the method printList which outputs the list to the output file.

Complete the recursive method countList which counts the number of items on the list

Complete the code for method LinkedMergeSort as indicated


Here is my code:



Thanks for any help anyone can give me. Joe.
17 years ago
I have tried to get this started and have the following done so far but don't know if i am going in the right direction. If anyone could help that would be great.

17 years ago
Ok, i have completed this piece of code and it compiles and runs -




I now have the following which i need to do - Create an array of Comparable Account objects in account number order (or use the output from the above code i have already completed) then implement a recursive Binary search for an item.

I'm not sure where to get started on this question. Any help would be appreciated. Thanks.
17 years ago
I have decided to make the list of comparible objects Account objects -



Where should i put my compareTo method in my code now?? And what should i be changing in following line of code to make the comparison work?? -



Thanks.
17 years ago
I have to modify a MergeSort method to sort a list of Comparable objects.
I also have to modify the code to determine how many comparisons of items occur during the sorting process by incrementing a class level variable comparisons and then use the program to confirm the theoretical predictions of performance for Mergesort.

Here is the MergeSort Method -



I'm not sure of where to begin with this problem, and any help would be appreciated. Thanks.
17 years ago
How do i install the Junit thing... i can't follow the installation guidelines on the website, thanks.
18 years ago
I have the Date and Transaction class and i need to test them so i have to write an application class. How do i go about doing this?

Here is the transaction class -

18 years ago
It says "Error: Invalid Input" at the bottom of my applet once you press one of the memory function buttons. Has anyone got any ideas how i can get these buttons to work? Thanks.
18 years ago
Here is my calculator code -



Any ideas why the memory buttons aren't working? Am i parsing an empty string here -



If i am how do i fix this problem? Thanks.
18 years ago
If i added these to my code would it solve the errors?

18 years ago
When i compile my piece of code i get the following errors -

C:\jexp>javac banktest.java
banktest.java:182: cannot find symbol
symbol : method getType()
location: class BankAccount
if(getType())
^
banktest.java:184: cannot find symbol
symbol : method getAmount()
location: class BankAccount
return currentBalance - getAmount();
^
banktest.java:190: cannot find symbol
symbol : method getType()
location: class BankAccount
if(!getType())
^
banktest.java:192: cannot find symbol
symbol : method getAmount()
location: class BankAccount
return currentBalance + getAmount();
^
banktest.java:192: operator + cannot be applied to double,getAmount
return currentBalance + getAmount();
^
banktest.java:192: incompatible types
found : <nulltype>
required: double
return currentBalance + getAmount();
^
banktest.java:207: cannot find symbol
symbol : method readDate()
location: class Transaction
list[i].readDate();
^
7 errors


Here is the code -



How can i fix these errors? Thanks.
18 years ago
Here is the printTransaction -



Any opinions?
18 years ago
For the classDate, i have got the following so far for what has to be completed. Could anyone tell me how this is looking -



And can anyone help me with calling the validDate method.. i don't know how! Thanks. (The classDate code is ^^^)
18 years ago
Aditionally, i've also been given some unfinished code and asked to complete it. This consists of two classes - the ClassDate and the ClassTransaction.

ClassDate code -

class Date
{// properties
private int day, month, year;

public Date (Date d) {
day = d.day;
month = d.month;
year = d.year;
}

public Date () {
}

// methods
public void readDate(){

//TO BE COMPLETED

}//readDate

public void printDate() {
System.out.print(day + "/" + month + "/" + year);
}//printDate

public boolean validDate()
{if (!validYear(year))
return false;
else if (!validMonth(month))
return false;
else if(!validDay(day,month))
return false;
else
return true;
}//validDate

private boolean validYear(int y)
{if ((y < 1990) || (y > 2100))
return false;
else
return true;
}//validYear

private boolean validMonth(int m)
{if ((m < 0) || (m > 12))
return false;
else
return true;
}//validMonth

private boolean validDay(int d, int m)
{if ((d < 0) || (d > daysinMonth(m)))
return false;
else
return true;
}//validDay

private int daysinMonth(int m)
{int NumDays;
switch(m)
{case 1:case 3:case 5:case 7:
case 8:case 10:case 12 : NumDays = 31;
break;
case 4:case 6:case 9:case 11:
NumDays = 30;
break;
case 2 : NumDays = 28;
break;
default: NumDays = 0;
}
return NumDays;
}//daysinMonth


} // end of class Date

The readDate method should prompt the user and read in relevant values for day, month and year and should determine whether the dates are valid by calling the method validDate.

Any ideas on how i can complete this code ^^^ ?


ClassTransaction code -

class Transaction {

private double amount;
private double newBalance;
private boolean type;
private Date d;

public void readTransaction() {
char c;
d = new Date();
d.readDate();

do
{
System.out.print("Is this transaction a withdrawal or deposit? (W or D)
");
c = uuInOut.ReadChar();
uuInOut.ReadLn();

if (c != 'W' && c != 'w' && c != 'D' && c != 'd')
System.out.println("Invalid entry. Try again.");

}while (c != 'W' && c != 'w' && c != 'D' && c != 'd');

if (c == 'W' || c =='w')
type = true;
else
type = false;
System.out.print("Enter amount: ");
amount = uuInOut.ReadDouble();
}

public void printTransaction() {

//TO BE COMPLETED

}

public boolean getType() {
return type;
}

public double getAmount() {
return amount;
}

public void setBalance(double value) {
newBalance = value;
}
}

Complete the class Transaction, by providing code for the method printTransaction.

Again any help with finishing the above code?

Thanks alot again for any help you can provide!
18 years ago
I'm pretty new to Java, and have been given this problem to solve. I'm just finding it difficult to get started, so was wondering if anyone could give me some help to get the ball rolling. Lots of thanks in advance!

Here's my task -

A bank requires software to deal with customer accounts. In particular, it should keep a record of transactions that are carried out, adjusting the balance of the account accordingly.

The software should carry out the following:

1. Permit the user to enter the relevant details for up to 100 transactions for a given bank account. (In each case the user should be prompted for the date, amount of money for the transaction, and whether it was a withdrawal or a deposit.)

2. Adjust the balance after each transaction depending on whether it was a withdrawal or deposit. (These are the only two types of transactions to be considered.)

3. Print out a bank statement in the following format:

******************************************
Name: Tom White
Account Number: 89475020
Current Balance: 200.00OD
******************************************
Transactions
28/12/2005 1500.00 1500.00 D
1/1/2006 550.00 950.00 W
14/1/2006 50.00 1000.00 D
18/1/2006 1200.00 200.00OD W
******************************************

(Note that the number appearing after the date is the amount for the transaction, the next number is the resulting balance with OD for overdrawn and W and D for withdrawal and deposit respectively.)

You should write a class BankAccount, which will have relevant properties for an account including an array of instances of the class Transaction, as well as an appropriate constructor and methods. The methods should include methods for depositing or withdrawing money (see notes); an addTransaction method to add a new instance to the array, read in its details (including date, etc.) and update the balance using the deposit or withdraw methods; a printStatement method to give a printout as indicated above.

You should write an application program which makes use of the above classes. Since it is only used for testing the other classes only a single instance of BankAccount needs to be created. The user should be allowed to add as many transactions as required (up to 100). Finally, it should print out the statement.

Writing the class bankAccount ^^ and Application program ^^ are what are giving me trouble. Can anyone help? Thanks!
18 years ago