Question: Grocery Run Write a method named calculateCheckout ( ) that takes 4 double parameters named foodItem 1 , foodItem 2 , foodItem 3 , and

Grocery Run
Write a method named calculateCheckout() that takes 4 double parameters named foodItem1, foodItem2, foodItem3, and taxRate, and returns the total food cost including tax.
This method will add the total cost of the food items, calculate the tax and return a double which represents the total food cost including tax.
The method should do the following:
Add the total of the food costs
Calculate the sales tax
return a double which is the total of the food order including tax.
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class GroceryCart {
// Write your static method here
/***** DO NOT CHANGE THE CODE BELOW THIS LINE *****/
public static void main(String[] args){
Scanner in = new Scanner(System.in);
double foodItemCost1, foodItemCost2, foodItemCost3, taxRate;
foodItemCost1= in.nextDouble();
foodItemCost2= in.nextDouble();
foodItemCost3= in.nextDouble();
taxRate = in.nextDouble();
System.out.println("Your grocery cart total is: $"+ String.format("%,.2f", calculateCheckout(foodItemCost1, foodItemCost2, foodItemCost3, taxRate)));
}
}
Expected STDOUT
Your grocery cart total is: $8.80

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!