Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

NEEDED IN C# Expand program 3 to calculate the total amount due from a group of

ID: 3664954 • Letter: N

Question

NEEDED IN C#

Expand program 3 to calculate the total amount due from a group of customers. The program first asks for the number of customers in the group. Then it uses a loop to take the orders one by one. If a customer orders something not on the menu, ignore that order and move on to the next customer. Use the number of customer in the group to determine how many times the loop will execute. Do not ask the user to enter a special value such as -1 to stop the loop. Calculate and display the total amount of money the group needs to pay.  

Explanation / Answer

#include //Always use meaningful names for types typedef unsigned char boolean; #define True 't' #define FALSE (!True) //this is a really neat trick for swapping values efficiently void swap(long* a,long *b) { *a=*a^*b;*b=*b^*a;*a=*a^*b; } //Here's a readability improvement #define until(condition) while(!(condition)) int main(int n, char*args[]){ double *d; int i; char input[5]; //should be long enough for most doubles. boolean sorted = FALSE; //In C, you need to specify the array size beforehand, so ask printf("Please enter the length of the array "); gets(input); //scan the input string and convert to a value sscanf(input,"%s",&input[0]); n=(long)atol(input); //allocate space, make sure you get the order of arguments right. d = calloc(sizeof(double),n); //Get and sort the array until (sorted) { for (i=0;i