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
|
/*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)
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");
}
|