I need to take this "over" statement under the overallmethod as finalmethods' parameter, how can I do this. I want to learn the final letter but to do that I want to access over statement.
public static void overallmethod(int quiz1,int quiz2,int quiz3,int midterm,int grade){
double quizzes = ( ((quiz1*10) + (quiz2*10) + (quiz3*10)) *25) /300;
double finalg = ( grade * 40) / 100;
double mid = (midterm * 35) / 100;
double over = quizzes + finalg + mid;
System.out.println("Your overall score is: " + over);
}
public static void finalmethod(double over){
if(over <= 100 && over >= 90){
System.out.println("Your final letter is: A");
}
else if(over >= 80) {
System.out.println("Your final letter is: B");
}
else if (over >= 70) {
System.out.println("Your final letter is: C");
}
else if (over >= 60) {
System.out.println("Your final letter is: D");
}
else{
System.out.println("Your final letter is: F");
}
}
You're going to need to return the variable over and change your return type to double.
public static double overallmethod(int quiz1,int quiz2,int quiz3,int midterm,int grade)
{
//Your code
return over;
}
Then simply pass the value returned from the overallmethod to finalmethod.
over is not a statement, it is a local variable now. Just make it class attribute:
public static double over
Make your overall function return the value of over. Then just call the overall function inside the parameter list of finalmethod
The best solution would be to declare over as a private int outside both the methods, i.e. it should have visibility to all the methods in that class (class variable).
Now compute the overall score in the overallMethod and store it to the over variable.
Next, make a public method getOver() which returns the value of over, and call finalMethod in this way : ClassName.finalMethod(objectOfClass.getOver())
By changing the return type of your method to double, and then passing the value in that method to the final method.
Related
I finally got my program to compile without any errors and the first half is correct the total pay, retirement deduction and net pay were all displaying 0. I saw from a different post that Java doesn't analyze the logic of your if blocks so I edited my code to have my rate assigned to 0 and my if statement to return rate. I'm now getting the error "unexpected return value". How do I get my program to have the appropriate value depending on the user's input?
import java.util.*;
public class AcmePay {
public static void main(String[] args) throws Exception {
Scanner keyboard = new Scanner(System.in);
double hours;
int shift;
int plan;
double rate = 0;
double overtimePay;
double paycheck;
//double retirement;
// double retirement = paycheck - (paycheck * .03);
//double netPay = paycheck - retirement;
System.out.println("How many hours did you work this week?");
hours = keyboard.nextDouble();
if ( hours <= 40 )
{
paycheck = hours * rate;
}
else
{
paycheck = (40 * rate) + ((hours - 40)) * (rate*1.5);
}
System.out.println("What shift did you work? 1, 2, or 3?");
shift = keyboard.nextInt();
if (shift == 1)
{
rate = 17;
return rate;
}
else if (shift == 2)
{
rate = 18.50;
return rate;
}
else if (shift == 3)
{
rate = 22;
return rate;
}
To print the rate, the last part of your code can be like this:
shift = keyboard.nextInt();
if (shift == 1) {
rate = 17;
} else if (shift == 2) {
rate = 18.50;
} else if (shift == 3) {
rate = 22;
}
System.out.println("Rate = " + rate);
i.e. remove the return statements and then print the rate at the end. You can't return a value from a void method like main(), hence the error.
If you want to calculate the rate using a separate method, you would do something like this:
private static double rateForShift(int shift) {
if (shift == 1) {
return 17;
} else if (shift == 2) {
return 18.50;
} else if (shift == 3) {
return 22;
}
return 0;
}
This method returns a double, so now you can (and have to) use return statements.
You would call it from the main method with:
double rate = rateForShift(shift);
It's a good idea to split your code into focused methods, like this, because it makes it easier to read and work with.
I think your code has a "logic" bug in it because you are using the rate variable to calclulate paycheck, but the rate variable is always 0 at the point you use it. You should probably ask both questions before you calculate the paycheck amount.
A full program would look like this:
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("How many hours did you work this week?");
double hours = keyboard.nextDouble();
System.out.println("What shift did you work? 1, 2, or 3?");
int shift = keyboard.nextInt();
double paycheck = calculatePayCheck(rateForShift(shift), hours);
System.out.println("Paycheck = $" + paycheck);
}
private static double calculatePayCheck(double rate, double hours) {
if (hours <= 40) {
return hours * rate;
} else {
return (40 * rate) + ((hours - 40) * (rate * 1.5));
}
}
private static double rateForShift(int shift) {
if (shift == 1) {
return 17;
} else if (shift == 2) {
return 18.50;
} else if (shift == 3) {
return 22;
}
return 0;
}
In Java programs you don't need to declare your variables at the top. The convention is to declare them as you need them.
Example
How many hours did you work this week?
20
What shift did you work? 1, 2, or 3?
2
Paycheck = $370.0
It's also worth mentioning that, although fine for a toy example, in a real system you should not use floating point numbers (like double) to represent money.
ELEVATE covered the code, so I'll cover the theory.
In Java (and in many other programming languages), a method is a block of code that may or may not take in an input and may or may not give an output. Whether or not the method gives an output can be determined by analyzing the method definition. If a primitive type (for example, int or double) or Object (for example, Scanner) is used in the method definition, then that method will return that type as output. If the keyword void is used in the method definition, then that method will return no output.
A key point to understand is this: Once a method is told to return a value, that method will terminate. Thus, you cannot include any code after a return statement, or your compiler will be angry with you and yell at you for including "unreachable code."
Now, to apply this to the specifics. The main method in Java uses the keyword void to indicate that it will not return any sort of output. Thus, return rate; is inappropriate for two reasons:
Returning a double value is indeed some sort of output, which contradicts the method definition of main in which main was set to return no output by the keyword void.
return rate; will cause your program to terminate immediately. Assuming that ELEVATE was correct about how you should reorder your code, leaving a return statement in your answer would cause you further problems by preventing your code from moving on to calculate your paycheck.
Side Note: A method that returns no output can still use the return keyword, but it cannot be used with any sort of value or object. For example, the following method is valid because return isn't paired with any sort of value.
public class ReturnExample {
/*Other stuff.*/
public void returnNothing() {
System.out.println("Now returning nothing.");
return;
}
}
}
I know the problem exists on the forum, but I am really stuck. I would like to call my grade() method into my display() method to appear the grade. I don't know how to do...
Here is my grade() method
public static void grade(int note){
String grade = "";
if (note <= 70){
grade = "Satisfaction";
}
else{
grade = "Great Satisfaction";
}
}
In my display() method, I want to retrieve the grade for the student.
public static void display(String[] tabStudent, int[] tabNote, char code){
for(int i=0; i<tabStudent.length;i++){
if (code == 'e'){
if (tabNote[ i ] < 50){
System.out.println(tabStudent[i] + " " + tabNote[i] );
}
}
else if(code == 's'){
if (tabNote[ i ] > 50){
System.out.println(tabStudent[i] + " " + tabNote[i] + grade() );
}
}
}
}
My problem is this line below:
System.out.println(tabStudent[i] + " " + tabNote[i] + grade() );
Here is an image
Thank you for your help.
tl;dr you're missing a return statement
Imagine you have a bunch of people around you who can either do a task (hopefully...) perfectly or can calculate some value (again, hopefully...) perfectly. When you tell one person, "go put coins into a vending machine", they go do it and walk back. They don't say anything, they just kind of...go. At most, you might get an "Ok" or a "HEY SOMETHING WENT WRONG" when they come back but that's the extent of their verbal capacity.
On the other hand, you have people who you ask "What are the 1st through 3rd letters of 'hello'?" And they will say, "'el'." They may go grab a calculator or a book to figure out the answer, but they can do it and will report the value back to you.
The former is an example of a void function, while the latter is what you get when you return from a function. When you have a function simply calculate values in a void function, it's equivalent to asking a friend, "What's 5+3?", them doing the calculation in their head and saying "done! :D". Not super helpful.
While there are ways to get around needing to return while not having to literally return (such as using global variables), they are heavily frowned up much like passing notes to relay information was in middle school by your teacher.
Well, it needs to actually return something:
public static String grade(int note){
String grade = "";
if (note <= 70) {
grade = "Satisfaction";
} else {
grade = "Great Satisfaction";
}
return grade;
}
I can see two issues in your code:
1. you should change return type of grade() method and return grade.
2. Your grade() method expect one parameter but you are not passing any while calling it. Try below code.
public static String grade(int note){
String grade = "";
if (note <= 70){
grade = "Satisfaction";
}
else{
grade = "Great Satisfaction";
}
return grade;
}
public static void display(String[] tabStudent, int[] tabNote, char code){
for(int i=0; i<tabStudent.length;i++){
if (code == 'e'){
if (tabNote[ i ] < 50){
System.out.println(tabStudent[i] + " " + tabNote[i] );
}
}
else if(code == 's'){
if (tabNote[ i ] > 50){
System.out.println(tabStudent[i] + " " + tabNote[i] + " " + grade(tabNote[i]) );
}
}
}
}
The first problem is that you do not have a method grade(). Instead, you have defined grade(int note) which expects an integer.
Even if you correct this problem and call grade like
System.out.println(tabStudent[i] + " " + tabNote[i] + grade(80));
it won't work because you have declared grade as
public static void grade(int note)
which should be
public static String grade(int note)
i.e. return type should be String instead of void as per your requirement.
Define it as
public static String grade(int note){
String grade = "";
if (note <= 70){
grade = "Satisfaction";
}
else{
grade = "Great Satisfaction";
}
return grade;
}
I'm sure this has a simple solution, but I'm new to Java and can't work it out.
I have a subclass Payroll that extends a superclass Pay, it contains an overridden method called 'calc_payroll'. From this method, I want to call the superclass method of the same name, and assign the output to a variable in the overriding method. My code is below
public class Payroll extends Pay
{
public double calc_Payroll()
{
double grossPay = super.calc_Payroll();
double taxAmt = tax(grossPay);
double netPay = grossPay - taxAmt;
System.out.println(grossPay);
return netPay;
}
}
Below is the code from the calc_payroll method in the superclass
public double calc_Payroll()
{
double otRate = rate * 1.77;
double otHours = ttlHours - stHours;
if(stHours == 0)
{
grossPay = otHours * rate;
}
else
{
grossPay = ((stHours * rate) + (otHours * otRate));
}
System.out.println(stHours + "//" + otHours + "//" + rate);//for testing
return grossPay;
}
the superclass method functions without issue to calculate and return the gross pay when called from a different subclass, but when calling it from a method with the same name, the print line in the code above (that I have labelled for testing) displays zero's for all variables
Code for full 'Pay' class is below as requested
public class Pay
{
private double ttlHours;
private int stHours;
private double rate;
double grossPay = 0.0;
final double TAXL = 0.07;
final double TAXM = 0.1;
final double TAXH = 0.16;
public void SetHours(double a)
{
ttlHours = a;
}
public void SetHoursStr(int a)
{
stHours = a;
}
public void SetRate(double a)
{
rate = a;
}
public double GetHours()
{
return ttlHours;
}
public int GetStHours()
{
return stHours;
}
public double GetRate()
{
return rate;
}
public double taxRate()
{
double taxRate = 0.0;
if(grossPay <= 399.99)
{
taxRate = TAXL;
}
else if(grossPay <= 899.99)
{
taxRate = TAXM;
}
else
{
taxRate = TAXH;
}
return taxRate;
}
public double tax(double grossPay)
{
double ttlTax = 0.0;
if(grossPay < 400.00)
{
ttlTax += (grossPay * TAXL);
}
else if(grossPay < 900.00)
{
ttlTax += (grossPay * TAXM);
}
else
{
ttlTax += (grossPay * TAXH);
}
return ttlTax;
}
public double calc_Payroll()
{
double otRate = rate * 1.77;
double otHours = ttlHours - stHours;
if(stHours == 0)
{
grossPay = otHours * rate;
}
else
{
grossPay = ((stHours * rate) + (otHours * otRate));
}
System.out.println(stHours + "//" + otHours + "//" + rate);//for testing
return grossPay;
}
}
The subclass Payroll contains no other code
Below is the code that accepts user input to assign values to the initialized variables
public class CalPayroll extends Pay
{
Payroll nPay = new Payroll();
Accept Read = new Accept();
public void AcceptPay()
{
char select = '0';
while(select != 'e' && select != 'E')
{
System.out.println("Payroll Computation \n");
System.out.print("Enter number of hours worked (00.0) <0 for Quick exit>: ");
SetHours(Read.AcceptInputDouble());
System.out.print("Enter first number of hours straight (integer or 0 to disable): ");
SetHoursStr(Read.AcceptInputInt());
System.out.print("Enter hourly rate of worker (00.00): ");
SetRate(Read.AcceptInputDouble());
Screen.ScrollScreen('=', 66, 1);
Screen.ScrollScreen(1);
displayInfo();
System.out.println("e to exit, any other letter + <Enter> to continue");
select = Read.AcceptInputChar();
}
}
public void displayInfo()
{
NumberFormat currency = NumberFormat.getCurrencyInstance();
NumberFormat percent = NumberFormat.getPercentInstance();
System.out.println("Gross pay is :" + currency.format(calc_Payroll()));
System.out.println("Tax is :" + percent.format(taxRate()));
System.out.println("Net pay is :" + currency.format(nPay.calc_Payroll()));
Screen.ScrollScreen(1);
}
}
I'm confused!
Its clear from you code that ttlHours, stHours and rate are not initialised with some reasonable value. So when you just call super.calc_Payroll(), values like 0 or 0.0 are used as i explained in my comment. Its good to first set values of these variables before calling super.calc_Payroll().
SetHours(23.4); //some value
SetHoursStr(5); //some value
SetRate(2.3); //some value
Also you don't have constructor for Pay class, try making it and initialising all uninitialised variable in constructor or use setter/getter methods to set and get values.
Since your both classes extends Pay class, it creates the problem which you are facing. When you call SetHours(Read.AcceptInputDouble()), it set the variable inherited by CalPayroll from Pay, not the variables inherited by Payroll class. What you have to do is to set variables for Payroll instance as well as for current class as both extends Pay. Do the following replace your while loop as,
while(select != 'e' && select != 'E')
{
System.out.println("Payroll Computation \n");
System.out.print("Enter number of hours worked (00.0) <0 for Quick exit>: ");
SetHours(Read.AcceptInputDouble());
nPay.SetHours(GetHours());
System.out.print("Enter first number of hours straight (integer or 0 to disable): ");
SetHoursStr(Read.AcceptInputInt());
nPay.SetHoursStr(GetStHours());
System.out.print("Enter hourly rate of worker (00.00): ");
SetRate(Read.AcceptInputDouble());
nPay.SetRate(GetRate());
Screen.ScrollScreen('=', 66, 1);
Screen.ScrollScreen(1);
displayInfo();
System.out.println("e to exit, any other letter + <Enter> to continue");
select = Read.AcceptInputChar();
}
Please post the complete code.
It seems that for some reason your variables of super class method not getting assigned values properly. And they are initialized with their default values which is making everything 0. I'll be able to help better if you paste the complete class.
public class PizzaEx {
/**
* #param args the command line arguments
*/
public static void main(String[] args) {
char letter;
String input;
int sizeD;
int pizzaCount=1;
Pizza pieOne;
do{
sizeD = getValidSize();
input = JOptionPane.showInputDialog(null, "What type of topping do you wish to order? " +
"\n Green Pepper" +
"\n Mushroom"+
"\n Sausage"+
"\n Pepperoni"+
"\n Plain");
pieOne = new Pizza(sizeD, input);
System.out.println(pieOne);
System.out.println("The Number of pizzas made are " + pieOne.getPizzaCount() +"."+"\n");
input = JOptionPane.showInputDialog(null, "Do you wish to continue?\n "+
"'y' or 'Y' for YES\n"+
"'n' or 'N' for NO\n");
letter = input.charAt(0);
pizzaCount = pizzaCount +1;
}
while (letter == 'Y'|| letter == 'y');
System.exit(0);
}
private static int getValidSize()
{
int d;
String input;
do{
input = JOptionPane.showInputDialog(null, "What size of pizza do you wish to order? "+
"\n 9 inch"+
"\n 12 inch"+
"\n 16 inch");
d = Integer.parseInt(input);
} while (!(d==9 || d==12 || d==16));
return d;
}
so the above is my main class
public class Pizza {
private int diameter;
private int numOfPizza;
private double price;
private String tops;
Pizza(int sizeD, String input) {
diameter = sizeD;
tops = input;
}
public int getDiameter(){
return diameter;
}
/**
*
* #param pizzaCount
* #return
*/
public int getPizzaCount(){
return numOfPizza;
}
public double getPrice(){
return price;
}
public String getToppings(){
return tops;
}
public void setDiameter(int sizeD){
if (sizeD == 9)
diameter = 9;
else if ( sizeD == 12)
diameter = 12;
else if (sizeD == 15)
diameter = 15;
else
diameter = 0;
}
public void setPizzaCount(int pizzaCount){
numOfPizza = pizzaCount;
}
public void setPrice(double total){
price = total;
}
public void setToppings(String input){
if ("green pepper".equalsIgnoreCase(input))
tops = "Green Pepper";
else if ("mushroom".equalsIgnoreCase(input))
tops = "Mushroom";
else if ("sausage".equalsIgnoreCase(input))
tops = "Sausage";
else if ("pepperoni".equalsIgnoreCase(input))
tops = "Pepperoni";
else
tops = "Plain";
}
private double calculatePrice(int sizeD, String input){
double total;
if (sizeD == 9 && (tops).equalsIgnoreCase("plain"))
total = 5.95;
else if (sizeD == 9)
total = 6.95;
else if (sizeD == 12 && (tops).equalsIgnoreCase("plain") )
total = 7.95;
else if (sizeD == 12)
total = 8.95;
else if (sizeD == 16 && (tops).equalsIgnoreCase("plain"))
total = 9.95;
else if (sizeD == 16)
total = 10.95;
else
total = 0.0;
return total;
}
public String toString(){
String pizzaString ="You have ordered a "+diameter + " inch pizza with "+tops +" toppings and a price of $"+ calculatePrice(diameter, tops);
return pizzaString;
}
When I do the the print out, it keeps saying amount of pizza made are = 0 even though I set pizzaCount = 1. Also when it ask for topping, if I type any String besides the valid topping choices {"green peppers", "mushroom", "sausage", "pepperoni", "plain"} it will count the String as a topping and will be charged for the topping when it should be anything that is not {"green peppers", "mushroom", "sausage", "pepperoni"} should be considered "plain"
This is not a homework assignment or test problem. It was some extra practice handed out by my professor and is not for a grade. I just want some help to clarify why the String tops is not being assigned the value that the method setToppings() is calling to do.
The reason why you always get 0 with getNumOfPizza() is because you never increment int numOfPizza, you only increment pizzaCount in main.
As for the topping, the reason why you charge for toppings even if you enter an invalid String, is because of your logic in calculatePrice, where you charge for topping if !equalsIgnoreCase("plain"). In other words, anything except for "plain" will be considered a topping. In fact, the logic in this method is unnecessarily convoluted, I suggest you simplify some of the if statements:
private double calculatePrice(int sizeD, String input){
if(!(tops).equalsIgnoreCase("plain")) {
total = 1;
} else {
total = 0;
}
if(sizeD == 9) {
total += 5.95;
}
else if(sizeD == 12) {
total += 7.95;
}
else if(sizeD == 16) {
total += 9.95;
}
return total;
}
Your class Pizza has a field private int numOfPizza; which you are accessing with pieOne.getPizzaCount(). Because that field hasn't been initialized (and it is a primitive int) it has a default value of 0. One possible fix,
private int numOfPizza = 1;
Be sure that you are considering which count you are interested in; the local count or the Pizza count. Once that is fixed, you should also change
pizzaCount = pizzaCount +1;
to something like
pizzaCount += pieOne.getPizzaCount();
You have the following constructor:
Pizza(int sizeD, String input) {
diameter = sizeD;
tops = input;
}
As you can see it does not run your logic from setToppings.
It also does not set numOfPizza and you do not call your setPizzaCount() method either. So this class variable remains 0
You seem to have two different fields to hold the number of pizzas. The pizza class should only hold data about the individual pizzas and the other class should hold the data about the amount of pizzas. In your main class you initialize pizzaCount to 1, but then try getting the number from the pizza numOfPizza field.
Edit Also, on a separate note, your main class has too much going on in there. You should abstract some stuff out and put it in methods.
When you print:
System.out.println("The Number of pizzas made are " + pieOne.getPizzaCount() +"."+"\n");
you are accessing pieOne. Lets check initialization:
Pizza pieOne = new Pizza(sizeD, input);
where sizeD stores the pizza size (like 9) and input stores a String.
The function pieOne.getPizzaCount() checks inside pieOne and returns numOfPizza;
public int getPizzaCount(){
return numOfPizza;
}
But since you never actually stored that value inside the object, it will return zero!
You net to call setPizzaCount() before printing anything.
Hope it helps.
The reason the String for toppings is coming back as whatever the user types every time is because the setToppings() method is declared but never called. You need to call it on the "tops" variable for it to work. As it is, the program skips the method altogether.
Here is one way you could call the method in your program:
public String toString()
{
//method call
setToppings(tops);
String pizzaString = "You have ordered a " + diameter + " inch pizza with " + tops + " toppings and a price of $" + calculatePrice(diameter, tops);
return pizzaString;
}
}
The problem with your number of pizzas is the same situation. The setPizzaCount() method had never been called, therefore numOfPizza was never set. Since int variables automatically default to 0 if they are not instantiated, you get a value of 0 every time. Also, you may want to consider using the increment (++) operator when you add one to the number of pizzas. It exists to help make your code easier for you to write and for others to understand when incrementing numbers.
Here's an example:
do
{
sizeD = getValidSize();
input = JOptionPane.showInputDialog(null, "What type of topping do you wish to order? " +
"\n Green Pepper" +
"\n Mushroom" +
"\n Sausage" +
"\n Pepperoni" +
"\n Plain");
pieOne = new Pizza(sizeD, input);
//method call
pieOne.setPizzaCount(pizzaCount);
System.out.println(pieOne);
System.out.println("The Number of pizzas made are " + pieOne.getPizzaCount() + "." + "\n");
input = JOptionPane.showInputDialog(null, "Do you wish to continue?\n " +
"'y' or 'Y' for YES\n" +
"'n' or 'N' for NO\n");
letter = input.charAt(0);
pizzaCount++;
}
import java.util.Scanner;
public class Hw4Part4 {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
//Ask for the diners’ satisfaction level using these ratings: 1 = Totally satisfied, 2 = Satisfied,
//3 = Dissatisfied.
System.out.println("Satisfacion leve: ");
int satisfactionNumber= sc.nextInt();
//Ask for the bill subtotal (not including the tip)
System.out.println("What is the bill subtotal: ");
double subtotal= sc.nextInt();
//Report the satisfaction level and bill total.
System.out.println("The satisfaction level is: "+ satisfactionLevel(satisfactionNumber));
System.out.println("The bill total is: " + getBillTotal(tipPercentage, subtotal));
}
public static String satisfactionLevel(int satisfactionNumber){
String satisfactionL = "";
if (satisfactionNumber == 1){
satisfactionL ="Totally-satisfied";
}
if (satisfactionNumber == 2){
satisfactionL = "Satisfied";
}
if (satisfactionNumber == 3){
satisfactionL = "Dissatisfied";
}
return satisfactionL;
}
//This method takes the satisfaction number and returns the percentage of tip to be
//calculated based on the number.
//This method will return a value of 0.20, 0.15, or 0.10
public static double getPercentage(int satisfactionNumber){
double getPercentage = 0;
if (satisfactionNumber ==1){
getPercentage = 0.20;
}
if (satisfactionNumber ==2){
getPercentage = 0.15;
}
if (satisfactionNumber ==3){
getPercentage = 0.10;
}
return getPercentage;
}
public static double getBillTotal(double tipPercentage, double subtotal){
double totalWithTip= (subtotal + ( getPercentage(satisfactionNumber) * subtotal));
return totalWithTip;
}
}
I am having issues on the last method, the whole code is shown above.
It says there is error with the part where I am trying to use the previous method.
I need to get the percentage which was computed on the previous method.
At this part of the code:
public static double getBillTotal(double tipPercentage, double subtotal){
double totalWithTip= (subtotal + ( getPercentage(satisfactionNumber) * subtotal));
return totalWithTip;
}
You call this method:
getPercentage(satisfactionNumber)
However, this variable:
satisfactionNumber
Doesn't exist in this method's scope. You should pass this variable to the method as so:
public static double getBillTotal(double tipPercentage, double subtotal, int satisfactionNumber){
double totalWithTip= (subtotal + ( getPercentage(satisfactionNumber) * subtotal));
return totalWithTip;
}
So when you call the method in the main, you pass it in:
System.out.println("The bill total is: " + getBillTotal(tipPercentage, subtotal, satisfactionNumber));
tipPercentage cannot be resolved to a varible
Pretty much any variable you pass in, you must create. So when you do the above line, make sure you have all variables delcared:
double tipPercentage, subtotal, satisfactionNumber;
//now set these three variables with a value before passing it to the method
System.out.println("The bill total is: " + getBillTotal(tipPercentage, subtotal, satisfactionNumber));
It's hard to tell, but I think you need to remove whitespace:
double totalWithTip = subtotal + (getPercentage(satisfactionNumber) * subtotal);
return totalWithTip;
This code assumes a variable:
int satisfactionNumber;
and a method:
double getPercentage(int satisfactionNumber) {
// some impl
}