i was assigned a question to design a java program to calculate the price of a pizza, this is what I tried:
String diameter;
diameter = this.txtInput.getText();
// variable declaration and intialize for "labourCost" and "storeCost"
double labourCost, storeCost;
labourCost = 1;
storeCost = 1.5;
// convert the value inputted from a string to double
double dblDiameter= Double.parseDouble(diameter);
// variable declarationa and intialize the value for the variable "cost"
double cost = (labourCost + storeCost + (0.5 * dblDiameter));
// print the output
this.lblOutput.setText("The cost of the pizza is $" + cost);
The output I got is $7.5, my question is how can I format it so it will display $7.50? thank you.