I got homework in ms server 2003 class and andvanced C programming
ms class have to take study notes over 3 chapters sounds easy right? wrong! each chapter in the book is about 105 pages!!! needless to say my fingers hurt from typing in ms word.
in advanced C I have to do a walk trough of this program:
/* Array menu */
#include <stdio.h>
#include <conio.h>
#include <process.h>
/* Global Variable Declarations */
double sub_total = 0;
double final_total = 0;
int index;
int outdex;
int loopcount;
/* Function Definitions */
void menu(void);
char getselect();
int getpounds(char []);
double gettotals(char[], int[]);
void ending(void);
int main()
{
char selection[10];
int pounds[10];
while(1)
{
system("cls");
menu();
for (index = 0; index <= 10; index++)
{
selection[index] = getselect();
pounds[index] = getpounds(selection);
loopcount++;
}
system("cls");
for (outdex = 0; outdex < loopcount -1; outdex++)
{
final_total = gettotals(selection, pounds);
}
ending();
}
return 0;
}
//************************************************** ******************
/* Function Definitions */
void menu(void)
{
printf("\n\nWelcome to Buff's Deli");
printf("\n");
printf("\nA. Ham $1.99lb.");
printf("\nB. Turkey $2.99lb.");
printf("\nC. Roast Beef $3.99lb.");
printf("\nX. Exit");
}
//************************************************** ******************
char getselect()
{
char s;
printf("\nEnter your selection: ");
scanf("%s", &s);
return (s);
}
//************************************************** ******************
int getpounds(char selection[])
{
int p;
if (selection[index] == 'x')
{
p = 0;
index = 11;
}
else
{
printf("Enter the amount of pounds now: ");
scanf("%d", &p);
}
return(p);
}
//************************************************** ******************
double gettotals(char selection[], int pounds[])
{
switch(selection[outdex])
{
case 'a': case 'A':
sub_total = 1.99 * (float) pounds[outdex];
printf("\n\nYour sub total for %d(s) of Ham is: %.2lf", pounds[outdex], sub_total);
break;
case 'b': case 'B':
sub_total = 2.99 * (float) pounds[outdex];
printf("\n\nYour sub total for %d(s) of Turkey is: %.2lf", pounds[outdex], sub_total);
break;
case 'c': case 'C':
sub_total = 3.99 * (float) pounds[outdex];
printf("\n\nYour sub total for %d(s) of Roast Beef is: %.2lf", pounds[outdex], sub_total);
break;
case 'x': case 'X':
sub_total = 0;
outdex = 3;
break;
default:
{
sub_total = 0;
printf("\n\nYour choice of item %c from the menu was invalid.\nYou were not billed for this selection.", selection[outdex]);
break;
}
}
final_total += sub_total;
sub_total = 0;
return (final_total);
}
//************************************************** ******************
void ending(void)
{
printf("\n\n\aYour Final Total is: $%.2lf", final_total);
final_total = 0;
loopcount = 0;
_getch();
system("cls");
}
A walk through is where you write each step that the program does like go through the for loops etc...
any help please?
