Aug 31, 2013 at 12:28am UTC
Hi, I'm new here, av got a troublesome issue, i'm creating a program dt accepts d NUMBER OF PANCAKES EATEN BY 10 PEOPLE, and orders them. I've created an object which does all of this, now i wrote that it sounds very low tech, but the problem is the program gives me a very wierd output,here's where i think d problem(s) is(are)...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
//creating class
class Pancakes
{
int pancakes[10];
void object_brain(int [10],short );
public :
void call_brain();
};
//implementation of member functions
void Pancakes::call_brain()
{
short reply;
puts("What do you wish to do?\n1.Check largest and least consumer\n2.See \
of ordered list for size of pancakes consumed\n3.EXIT\n->" );
cin>>reply;
object_brain(pancakes, reply);
}
void Pancakes::object_brain(int copy_pancakes[10],short reply)
{
short i = 0;
int a = 0;
short j = 0;
short s = 0;
//ordering(sorting) array
for (; i < 10; i++)
{
for (; j< 10; j++)
{
s = j + 1;
copy_pancakes[j] == copy_pancakes[s];
}
}
//matching order to persons
short x[10];
for (i = 0; i < 10; i++)
{
s = i + 1;
if ( pancakes[i] == copy_pancakes[9])
x[0] = s;
else if ( pancakes[i] == copy_pancakes[8])
x[1] = s;
else if ( pancakes[i] == copy_pancakes[7])
x[2] = s;
else if ( pancakes[i] == copy_pancakes[6])
x[3] = s;
else if ( pancakes[i] == copy_pancakes[5])
x[4] = s;
else if ( pancakes[i] == copy_pancakes[4])
x[5] = s;
else if ( pancakes[i] == copy_pancakes[3])
x[6] = s;
else if ( pancakes[i] == copy_pancakes[2])
x[7] = s;
else if ( pancakes[i] == copy_pancakes[1])
x[8] = s;
else if ( pancakes[i] == copy_pancakes[0])
x[9] = s;
}
//Producing output
switch (reply)
{
case 1:
cout<<"Largest consumer is Person " << x[0] << " with " ;
cout<< copy_pancakes[0] << " pancakes." <<endl;
cout<<"Laest consumer is Person " << x[9] << " with " ;
cout<< copy_pancakes[9] << " pancakes." <<endl;
redo();
break ;
case 2:
cout<<"They are ordered:" <<endl;
for (j = 1; j <= 10; j++)
{
s = j -1;
cout<<"Person " << x[j] << " - " << copy_pancakes[s] << "\
pancakes." <<endl;
}
redo();
break ;
case 3:
puts("OK.Bye!" );
break ;
default :
puts("Invalid response!" );
call_brain();
break ;
}
}
int main(int argc, char *argv[])
{
//Creating instance of class
Pancakes A;
A.call_brain();
system("pause" );
return 0;
}
Hope it's not too much code, if some more of the program is required i can post it up, i'd really appreciate anyone's help.God bless you!
Last edited on Sep 2, 2013 at 9:42pm UTC
Aug 31, 2013 at 12:33am UTC
How are you even running that? Your class and function definitions are inside your main().
Sep 2, 2013 at 9:44pm UTC
Oh yes, u r rait, bt dts not d way it actualy is, i did dt so i wont have 2 put in all d code, i was wrong thnks, i've editted it now so, please take another look.God bless u!