Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Java Programming 24-Hour Trainer by Yakov Fain
This is the forum to discuss the Wrox book Java Programming 24-Hour Trainer by Yakov Fain; ISBN: 978-0-470-88964-0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Java Programming 24-Hour Trainer by Yakov Fain section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old June 9th, 2011, 01:49 PM
Registered User
Join Date: Jun 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Lesson 3 Method Overriding.

I have the TestTax class;

class TestTax {
	public static void main (String[] args){
		NJTax t = new NJTax();
		t.grossIncome= 50000;
		t.dependents= 2;
		t.state= "NJ";
		double yourTax = t.calcTax();
		double totalTax = t.adjustForStudents(yourTax);
		System.out.println("Your tax is " + yourTax);
class tax {
	double grossIncome;
	String state;
	int dependents;
	public double calcTax(){
		double stateTax = 0;
		if(grossIncome < 30000){
			stateTax = grossIncome * 0.05;
			stateTax = grossIncome * 0.06;
		return stateTax;
	public void printAnnualTaxReturn(){
		// code goes here
public class NJTax extends tax{
	double adjustForStudents (double stateTax){
	double adjustedTax = stateTax - 500;
	return adjustedTax;
		public double calcTax(){
I am having trouble with the Lesson requirement to:
"Change the functionality of calcTax( ) by overriding it in NJTax. The new version of calcTax( ) should lower the tax by $500 before returning the value."

How is this accomplished. I just have safaribooksonline and no videos for the solution.
Reply With Quote
  #2 (permalink)  
Old June 16th, 2011, 05:11 PM
Registered User
Join Date: Jun 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

in your class for TestTax look at the println: ("Your tax is " + yourTax);

Try ("Your tax is " + totalTax);

That is the one you are using for the NJTax override.
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lesson 5 exercises. thelemur BOOK: Java Programming 24-Hour Trainer by Yakov Fain 9 March 29th, 2013 11:56 PM
Lesson 6 Try It zavodney BOOK: Stephens' Visual Basic Programming 24-Hour Trainer 2 June 6th, 2011 10:07 PM
Lesson 3 question soneal777 BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer 1 August 30th, 2010 06:17 PM
new keyword vs method overriding anand_instra C# 1 April 30th, 2008 01:46 PM
Overriding the ispostback method Indo77 ASP.NET 1.0 and 1.1 Basics 3 April 6th, 2005 02:50 PM

All times are GMT -4. The time now is 02:28 AM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.