Hi there!
Looking for some help with a simple c# console application program. I am working on an assignement and am really struggling to put the pieces together.
A brief of the assignment:
A Pizza making company produces bespoke Pizzas. Each one is a different size and quality, but
they are all round in shape.
The pizzas are priced as follows:
First, a fixed charge is made according to the quality. There are three levels of quality:
Supreme – The fixed charge is £5.00
Best brand – The fixed charge is £3.00
Regular – The fixed charge is £1.50.
Then a charge is made according to the area of the pizza, at a rate of £30 per square metre.
You should write a program to allow a sales assistant to calculate the price of a pizza, and then
store the details of each sale in a text file, to allow later analysis of sales data.
The program should ask the operator for the quality of the pizza. It is recommended that you use
“1” for Supreme, “2” for Best brand and “3” for Regular. To avoid the risk of operator error,
write the selection name back to the operator, and provide a means for the operator to cancel the
selection and re-enter the correct quality. You should trap operator errors (eg entering an invalid
number or text) and write a helpful message and request re-entry of the invalid data.
Next, ask for the diameter of the pizza in millimetres. Check for valid input as above. See the
note at the end that gives the limits that you should check for on the diameter.
Finally, print out the cost of the pizza in pounds and rounded to the nearest penny. After this is
done you should allow the sales assistant to confirm that the details and price are correct, or to
correct details (for example if a mistake was made); thus the operator can cancel the order and
start again.
Introduction to Programming: Evaluation Project
RACC Introduction to Programming
Page 2 of 2
The formula for the price is: Fixed charge + area (in square metres) x £30.
You can assume the pizzas are circular and thus you can calculate the area as Pi x r². (Where Pi
= 3.14159, and r is the radius of the circle.)
Key requirements:
- Use a string array to hold the description of the Pizzas. This array should be used to show a
menu of pizza qualities and should be used anywhere else you access the descriptions.
- You should save full details of each pizza sold (Quality, size, price and date / time sold) in a
file. This should be designed to allow sales reports to be produced later. (You don’t have to
produce the sales reports). The files should be text files to permit inspection of your results.
You can define your own data format, provided the necessary data is saved. There should
only be one sales record file, and the new records should be appended at the end.
- The Documentation should do the following:
1. Describe the flow or sequence of the program using a suitable methodology (for
example a flow chart or pseudo code.)
2. Comments should be included in the program to explain the function of the different
parts of the program. These should be good enough to help another programmer
maintain the program.
3. There is no need to repeat information in the specification above.
Here's what I have so far (having trouble with the array aspect to get the baseprice and also with strings converting into numbers):
static void Main(string[] args)
{
const double cost1 = 5;
const double cost2 = 3;
const double cost3 = 1.50;
const double pie = 3.14159;
double metrecost = 30;
const int SIZEMIN = 120;
const int SIZEMAX = 1000;
double radius;
string pizzasizeString;
double pizzasize;
double qualitycase;
double baseprice;
double pizzaprice;
//Console.WriteLine("Please enter which type of pizza the customer would like to buy \n 1. Supreme \n 2. Best Brand \n 3.Regular");
/*int [] baseprice = new int [2];
string input;
input = Console.ReadLine();*/
string[] selectcase = { "Supreme", "Best Brand", "Regular" };
for (int i = 0; i < selectcase.Length; i++)
Console.WriteLine("{0} {1}", i + 1, selectcase[i]);
Console.Write("Please enter which type of pizza the customer would like to buy: ");
double.Parse(qualitycase) = Console.ReadLine(); // Read input
if (qualitycase == 1)
{
baseprice = cost1;
}
else if (qualitycase == 2)
{
baseprice = cost2;
}
else if (qualitycase == 3)
{
baseprice = cost3;
}
else
{
Console.WriteLine("That is an invalid choice please select option 1, 2 or 3");
}
{ //Calculate area and cost of pizza
do
{
Console.Write("Please enter the size of the pizza that the customer would like to buy between " + SIZEMIN + " and " + SIZEMAX + " :");
pizzasizeString = Console.ReadLine();
pizzasize = double.Parse(pizzasizeString);
} while (pizzasize < SIZEMIN || pizzasize > SIZEMAX);
radius = (pizzasize / 2) / 1000; //Size is diameter in mm so divide by 2
//Divide by 100 to get metreage
pizzaprice = ((pie * (radius * radius)) * metrecost) + baseprice;
}
}
}
}
