2 Replies - 19089 Views - Last Post: 27 January 2013 - 06:59 PM Rate Topic: -----

#1 _RossTheBoss_  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 16-January 13

Tip Calculator Program

Posted 27 January 2013 - 06:41 PM

I'm creating a tip calculator program and I am having a few errors. This is what I have so far for my Tester class...
public class TipCalculatorTester
{	
	public static void main(String[] args)
	{
		TipCalculator Calculator = new TipCalculator();
		System.out.println("Please enter bill: ");
		TipCalculator.calculateBill();
		System.out.println("How much would you like to tip: ");
		Calculator.ShouldTip();
		Calculator.ShouldSplit();
	}
}


and this is my main class...
import java.util.Scanner;
public class TipCalculator
{
	double bill;
	double tip;
	double total;
	double split;
	double splitPrompt;
	double Y;
	double N;
	double billPerPerson;
	
		Scanner scan = new Scanner(System.in);
		public void calculateBill(double bill)
		{
			 bill = scan.nextDouble();
		}
		
		public void ShouldTip(double tip)
		{
			 tip = scan.nextDouble();
			if(tip<1)
			{
				total = bill * tip;
			}
		else total = bill * (tip/100);
		System.out.println("Your total is: " + total);
		}
		
		
		public void ShouldSplit(double splitPrompt)
		{
		System.out.println("Would you like to split the bill: ,1 for yes, 0 for No");
		splitPrompt = scan.nextDouble();
		if(splitPrompt == 0)
		{
			System.out.println("Your total is: " + total);
			System.out.println("Have a nice day");
			System.out.println("Program Terminated");	
		}
		if(splitPrompt == 1)
		{
			System.out.println("How many ways would you like to split the bill: ");
			splitPrompt = scan.nextDouble();
			billPerPerson = total/split;
			System.out.println("Each person pays: " + billPerPerson);
			System.out.println("Have a nice day");		
		}
		else System.out.println("Invalid Entry");
		}
		
	}


and I am getting an error on line 7 of my tester that says "error: method calculateBill in class TipCalculator cannot be applied to given types"

can someone help me? and thank you in advance for any help.

This post has been edited by macosxnerd101: 27 January 2013 - 06:43 PM
Reason for edit:: Fixed code tags. Code tags look like: [code] [/code]


Is This A Good Question/Topic? 0
  • +

Replies To: Tip Calculator Program

#2 tlhIn`toq  Icon User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6507
  • View blog
  • Posts: 14,373
  • Joined: 02-June 10

Re: Tip Calculator Program

Posted 27 January 2013 - 06:56 PM

You're calling the method with no arguments
07 TipCalculator.calculateBill();

But you defined the method to receive a double as a parameter.
14 public void calculateBill(double bill)
Also keep in mind that *this* bill is a new bill whose scope is only this method - It is not he same bill that you defined for the entire class on line 04.

You probably just want to drop out the parameter of line 14
14 public void calculateBill(double bill)
Was This Post Helpful? 0
  • +
  • -

#3 ccdan  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 107
  • Joined: 09-December 12

Re: Tip Calculator Program

Posted 27 January 2013 - 06:59 PM

You don't need "double bill" as a parameter in calculateBill definition... besides, it doesn't make sense multiply the bill by the tip if the tip is less than 1 ...
Was This Post Helpful? -1
  • +
  • -

Page 1 of 1