Pizza Hub sells pizzas of four sizes, S, M, L,
X. The prices are $6.99, $8.99, $12.50, and $15.00
respectively. For each pizza, there is an optional extra
topping that costs $1.00, $2.00, $3.25, and $4.50
for each size. Write a program to prompt a user to order one pizza
of any size, and then ask if an extra topping is needed. Based on
these, calculate and display the cost of the ordered pizza
accordingly. For this program, you need to use three
parallel arrays to hold the sizes, prices, the topping
costs, and you can use predefined array methods if needed.
Please Write this program in C#
using System;
class HelloWorld {
static void Main() {
char[] sizes={'S','M','L','X'}; //sizes array
double[] prices={6.99,8.99,12.50,15.00}; //prices array
double[] topping={1.00,2.00,3.25,4.50}; //topping array
char size_choice,topping_choice;
double total_cost=0.0;
Console.Write("Enter the size of the pizza(S,M,L,X): ");
size_choice=char.Parse(Console.ReadLine()); //inputting the size of
pizza
Console.Write("Do you want topping(Y/N): ");
topping_choice=char.Parse(Console.ReadLine()); //inputting whether
the customer wants toppings or not
for(int i=0;i<sizes.Length;i++){
if(size_choice==sizes[i]){ //checking the size_match
total_cost+=prices[i]; //adding the cost of the matched size
if(topping_choice=='Y'){ //if topping is choosen then
total_cost+=topping[i]; //add the cost of topping to the total
cost
}
break;
}
}
Console.Write("Total cost: $"+total_cost); //print the cost
}
}
Pizza Hub sells pizzas of four sizes, S, M, L, X. The prices are $6.99, $8.99,...