Question: I am getting an error message but I dont know the way to type itin and where. message is: bad operand types for binary operator

I am getting an error message but I dont know the way to type itin and where.

message is: bad operand types for binary operator "*" firsttype: string, Second type: string

here is the code:

/*
* To change this license header, choose License Headers inProject Properties.
* To change this template file, choose Tools |Templates
* and open the template in the editor.
*/
package week_2;
/**
*
* @author j0nny
*/
public class PRG215_Week_2 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {

System.out.println("Please enter theproduct ID(the number to the left of the item name) that you wishto purchase.");
int LoopCounter = 0;
int itemsToPurchase = 0;
String totalAmount = null;

//Loop the number of times the customerentered for the number of items
for(int loopCounter = 0; loopCounter< itemsToPurchase; LoopCounter++) {

//Promote the user andget item number from keyboard
System.out.print("Pleaseenter item ID number" + (loopCounter + 1) + ":");
int itemID =keyboard.nextInt();

//Test which item theuser entered
//User entered 1
if(itemID == 1)
{
StringtennisShoeCost = null;
totalAmount= totalAmount + tennisShoeCost;
}

//User entered 2
if(itemID == 2)
{
StringshirtCost = null;
totalAmount= totalAmount + shirtCost;
}

//User entered 3
if(itemID == 3)
{
StringcoatCost = null;
totalAmount= totalAmount + coatCost;
}

//User entered 4
if(itemID == 4)
{
StringbeltCost = null;
totalAmount= totalAmount + beltCost;
}
int itemId = 0;

//User entered 5
if(itemId == 5)
{
StringpantCost = null;
totalAmount= totalAmount + pantCost;
}

}
String taxRate = null;

//the loop is complete, calculate te taxes anddisplay the results
**** double taxAmount = totalAmount *taxRate;********* here is where I am getting theerror

//Show the results
System.out.println("");
System.out.println("Your sales total $" + totalAmount);
System.out.println("Your sales tax is $" + taxAmount);
System.out.println("The total amount due is $" + (totalAmount +taxAmount));
System.out.println("");
}
}

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!