Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualVaugeCookie

Posted 17 August 2013 - 08:45 AM

OK so here is my attempted code as you can see i am trying to somehow implement a way that i can join up the person who ate the most pancakes to their value of pancakes eaten, i have been bashing my face into the monitor for a few hours now and have finally conceded that i need help 

please could someone review my code and drop a few hints on how to make this work, 

[code=auto:0]

Once the data has been entered the program must analyze the data and output which person ate the most pancakes for breakfast.
*/
#include "iostream"
#include <stdio.h>

using namespace std;

int person[10]= { 0,0,0,0,0,0,0,0,0,0}; 

// i have written out this structure with the intention of being able to print out the name of person an cakes eaten as one item
// i haven't implemented it anywhere within the code because i dont have a clue how too make it work the way that i want.

//structure to hold person data and cakes eaten
typedef struct personalDetails
{
char name[10];
int index;

}personINFO;

//SORTING OUT
void findHighest()
{
int highest = -1;
int tempA = -1;
int tempB = -1;

for(int index = 0; index < 10; index++)
{
tempA = person[index];
tempB = person[index + 1];

if(tempA > tempB)
{
highest = tempA; 
}

}
cout << highest << " was the most pancakes eaten\n"; // i need to some how edit this line to print out who ate the most
}

int main (int args, char* argv[]){

//user input and instruction screen
cout << "--------------------------------PANCAKE-O-MATIC--------------------------------\n\n";
cout << "-----------please enter the number of pancakes eaten by each person------------\n\n";

for(int index = 0;index < 10; index++)
{
cout << "how many did person" << " " << index + 1 << " eat? "; // i know i need to change something here so that the number of pancakes eaten
cin >> person[index],"\n";                                                        // is attached to the person eating them i.e person 1 ate 2, person 2 ate 4 etc
}
//sort function
findHighest();

system("PAUSE");
}/*Write a program that asks the user to enter the number of pancakes eaten for breakfast by 10 different people (Person 1, Person 2, ..., Person 10)

[\CODE]


#1VaugeCookie

Posted 17 August 2013 - 05:17 AM

OK so here is my attempted code as you can see i am trying to somehow implement a way that i can join up the person who ate the most pancakes to their value of pancakes eaten, i have been bashing my face into the monitor for a few hours now and have finally conceded that i need help 

please could someone review my code and drop a few hints on how to make this work, 
Once the data has been entered the program must analyze the data and output which person ate the most pancakes for breakfast.
*/
#include "iostream"
#include <stdio.h>

using namespace std;

int person[10]= { 0,0,0,0,0,0,0,0,0,0}; 

// i have written out this structure with the intention of being able to print out the name of person an cakes eaten as one item
// i haven't implemented it anywhere within the code because i dont have a clue how too make it work the way that i want.

//structure to hold person data and cakes eaten
typedef struct personalDetails
{
char name[10];
int index;

}personINFO;

//SORTING OUT
void findHighest()
{
int highest = -1;
int tempA = -1;
int tempB = -1;

for(int index = 0; index < 10; index++)
{
tempA = person[index];
tempB = person[index + 1];

if(tempA > tempB)
{
highest = tempA; 
}

}
cout << highest << " was the most pancakes eaten\n"; // i need to some how edit this line to print out who ate the most
}

int main (int args, char* argv[]){

//user input and instruction screen
cout << "--------------------------------PANCAKE-O-MATIC--------------------------------\n\n";
cout << "-----------please enter the number of pancakes eaten by each person------------\n\n";

for(int index = 0;index < 10; index++)
{
cout << "how many did person" << " " << index + 1 << " eat? "; // i know i need to change something here so that the number of pancakes eaten
cin >> person[index],"\n";                                                        // is attached to the person eating them i.e person 1 ate 2, person 2 ate 4 etc
}
//sort function
findHighest();

system("PAUSE");
}/*Write a program that asks the user to enter the number of pancakes eaten for breakfast by 10 different people (Person 1, Person 2, ..., Person 10)

 


PARTNERS