'void' type not allowed here

I know that...but I need assistance

Page 1 of 1

3 Replies - 2878 Views - Last Post: 02 October 2009 - 11:33 PM Rate Topic: -----

#1 Condiment  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 05-September 09

'void' type not allowed here

Posted 02 October 2009 - 11:07 PM

Okay...

So heres my code

 System.out.println(" You" + System.out.print (client.getName()) + ", have a Net Yearly Salary of " + System.out.print (client.getNetSalary()) + " and pay $" + System.out.print (client.getTax()) + " worth of tax a year. This equates to $" + System.out.print (client.getNetSalary() / 52) + " net weekly salary and $" + System.out.print (client.getTax() / 52) + " weekly in tax. Your pay $ " + System.out.print (client.getGrossSalary()) - (client.getMedicare()) + " yearly in medicare levy" );




messy? yes, but i think It'll do the job...

however, BlueJ says that I can't use a void type here. Fair enough, I AM returning values, after all...however, I'm not USING any void types here is my proof:

 public String getName ()
	  {
	   //Gets the client's name
	   //Preconditions  -- none
		//Postconditions -- returns the name
		return name;
	  }	 
			   

 public double getNetSalary ()
	  {
		   return netSalary;
	  }	 

 public double getTax ()
		{ 
			return tax;
		}


 public double getGrossSalary ()
	  {
		  //Gets the client's gross Salary
		  //Preconditions -- none
		  //Postconditions -- returns gross Salary
		  return grossSalary;
		  
	   }



	  public double getMedicare ()
	  {
		  return medicare;
	  }   




I dunno...anything wrong? any guidance will be greatly appreciated :D

Is This A Good Question/Topic? 0
  • +

Replies To: 'void' type not allowed here

#2 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 729
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: 'void' type not allowed here

Posted 02 October 2009 - 11:26 PM

ouch..well you cant have print statements within print statements, why? because the print method is void and you cant print anything that is void..

System.out.println(" You" + client.getName() + ", have a Net Yearly Salary of " + client.getNetSalary() + " and pay $" + client.getTax() + " worth of tax a year. This equates to $" + (client.getNetSalary() / 52) + " net weekly salary and $" + (client.getTax() / 52) + " weekly in tax. Your pay $ " + (client.getGrossSalary() - client.getMedicare()) + " yearly in medicare levy" );



this should do it now

This post has been edited by mostyfriedman: 02 October 2009 - 11:27 PM

Was This Post Helpful? 0
  • +
  • -

#3 AntonWebsters  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 89
  • View blog
  • Posts: 428
  • Joined: 15-August 09

Re: 'void' type not allowed here

Posted 02 October 2009 - 11:26 PM

Something's wrong with your code...change it this way..see if it works.
 System.out.println(" You" +client.getName() + ", have a Net Yearly Salary of " + client.getNetSalary() + " and pay $" + client.getTax() + " worth of tax a year. This equates to $" + (client.getNetSalary() / 52) + " net weekly salary and $" + (client.getTax() / 52) + " weekly in tax. Your pay $ " + (client.getGrossSalary() - client.getMedicare()) + " yearly in medicare levy" );



EDIT: Beaten to the punch~ T_T

This post has been edited by AntonWebsters: 02 October 2009 - 11:27 PM

Was This Post Helpful? 0
  • +
  • -

#4 Condiment  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 05-September 09

Re: 'void' type not allowed here

Posted 02 October 2009 - 11:33 PM

cheers...my lecturer told me to put the print statements next to the method, So I thought it would be okay to put the print statements next to the method inside another print...I see where I went wrong...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1