# Tip Calculator Program

Page 1 of 1

## 2 Replies - 19532 Views - Last Post: 27 January 2013 - 06:59 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=309754&amp;s=6c6bcbd83f18a6e684624d5b78f0d183&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 _RossTheBoss_

Reputation: 0
• 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();
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

• Xamarin Cert. Dev.

Reputation: 6517
• Posts: 14,405
• 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)

### #3 ccdan

Reputation: 3
• 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 ...