8. Create a class named Pizza that stores details about a pizza. It should contain the following:
14. Instance Variables:
String pizzaSize - to store the size of the pizza (small, medium, or large)
int cheese - the number of cheese toppings
int pepperoni - the number of pepperoni toppings
int mushroom - the number of mushroom toppings
Member Methods:
Constructor - to initialise all the instance variables
CalculateCost() - A public method that returns a double value, that is, the cost of the pizza.
Pizza cost is calculated as follows:
Small: Rs.500 + Rs.25 per topping
Medium: Rs.650 + Rs.25 per topping
Large: Rs.800 + Rs.25 per topping
PizzaDescription() - A public method that returns a String containing the pizza size, quantity of each topping, and the
pizza cost as calculated by CalculateCost().
Answers
Answer:
CalculateCost() - A public method that returns a double value, that is, the cost of the pizza.
Pizza cost is calculated as follows:
Small: Rs.500 + Rs.25 per topping
Medium: Rs.650 + Rs.25 per topping
Large: Rs.800 + Rs.25 per topping
PizzaDescription() - A public method that returns a String containing the pizza size, quantity of each topping, and the
pizza cost as calculated by CalculateCost().
// CompoundInterest.java
import java.util.*;
public class CompoundInterest
{
public static double calculateAmount(double amount,
double rate, int years)
{
if(years <= 0)
return amount;
else
return calculateAmount(amount * (1 + rate / 100),
rate, years - 1);
}
public static void main(String[] args)
{
Scanner console = new Scanner(System.in);
System.out.print(
"Enter the amount of money to deposit: $");
double P = console.nextDouble();
System.out.print("Enter an interest rate per year: $");
double i = console.nextDouble();
System.out.print("Enter the number of years: ");
int n = console.nextInt();
double finalAmount = calculateAmount(P, i, n);
System.out.printf(
"\nFinal amount of money in the savings account: $%.2f", finalAmount);
}
}
mark as brainliest