i need help with line 34 and 35?

Watch this thread
J0EY1000
Badges: 2
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#1
Report Thread starter 1 year ago
#1
#include <iostream>

using namespace std;
double marks [6];

int minMax(double marks[6]) /*Question 2d*/

{
double max;
double min;
double minIndex;
double maxIndex;
for (int i = 0; i < 6; ++i)
{
max = 0;
if (marks[i] > max)
{
marks[i] = max;
maxIndex = i;
}

}

for (int i = 0; i < 6; ++i)
{
min = 0;
if (marks[i] < min )
{
marks[i] = min;
minIndex = i;
}

}
cout << "Your lowest mark was " << marks[minIndex] << endl;
cout << "Your highest mark is for " << marks[maxIndex] << endl;

}

int calcAverageYearMark(double eng, double math,double lo,double hist,double clit,double art) /*Question 2c*/
{
double totMark;
double avgMark;


totMark = marks[0] + marks[1] + marks[2] + marks[3] + marks[4] + marks[5];
avgMark = totMark / 6;

cout << "Your averge mark is " << avgMark << endl;
}

int getMarks(double eng, double math,double lo,double hist,double clit,double art) /*Question 2b*/
{


cout << "Key in your mark for English: ";
cin >> eng;
cout << "Key in your mark for Mathematics: ";
cin >> math;
cout << "Key in your mark for Life Orientation: ";
cin >> lo;
cout << "Key in your mark for History: ";
cin >> hist;
cout << "Key in your mark for Computer Literacy: ";
cin >> clit;
cout << "Key in your mark for Art: ";
cin >> art;

marks [0] = eng;
marks [1] = math;
marks [2] = lo;
marks [3] = hist;
marks [4] = clit;
marks [5] = art;
}


int studentDetails( string name, string school ) /*Question 2a*/

{
cout << "Please key in your name: ";
cin >> name;


cout << "Please key in the name of your school: \n";
cin >> school;


/*cout << "Your weight is " << name << endl;
cout << "Your height is " << school << endl;*/



}
0
reply
username1732133
Badges: 15
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#2
Report 1 year ago
#2
(Original post by J0EY1000)
#include <iostream>

using namespace std;
double marks [6];

int minMax(double marks[6]) /*Question 2d*/

{
double max;
double min;
double minIndex;
double maxIndex;
for (int i = 0; i < 6; ++i)
{
max = 0;
if (marks[i] > max)
{
marks[i] = max;
maxIndex = i;
}

}

for (int i = 0; i < 6; ++i)
{
min = 0;
if (marks[i] < min )
{
marks[i] = min;
minIndex = i;
}

}
cout << "Your lowest mark was " << marks[minIndex] << endl;
cout << "Your highest mark is for " << marks[maxIndex] << endl;

}

int calcAverageYearMark(double eng, double math,double lo,double hist,double clit,double art) /*Question 2c*/
{
double totMark;
double avgMark;


totMark = marks[0] + marks[1] + marks[2] + marks[3] + marks[4] + marks[5];
avgMark = totMark / 6;

cout << "Your averge mark is " << avgMark << endl;
}

int getMarks(double eng, double math,double lo,double hist,double clit,double art) /*Question 2b*/
{


cout << "Key in your mark for English: ";
cin >> eng;
cout << "Key in your mark for Mathematics: ";
cin >> math;
cout << "Key in your mark for Life Orientation: ";
cin >> lo;
cout << "Key in your mark for History: ";
cin >> hist;
cout << "Key in your mark for Computer Literacy: ";
cin >> clit;
cout << "Key in your mark for Art: ";
cin >> art;

marks [0] = eng;
marks [1] = math;
marks [2] = lo;
marks [3] = hist;
marks [4] = clit;
marks [5] = art;
}


int studentDetails( string name, string school ) /*Question 2a*/

{
cout << "Please key in your name: ";
cin >> name;


cout << "Please key in the name of your school: \n";
cin >> school;


/*cout << "Your weight is " << name << endl;
cout << "Your height is " << school << endl;*/



}
If you set min=0 then marks[i] will never be less than min and you won't find the location of the minimum mark.

By the way, you have posted this in the maths forum and whilst a lot of people here have probably done some programming there must be a better place for your question.

Also, if you're going to refer to line numbers it would help if the lines were actually numbered.
Last edited by username1732133; 1 year ago
1
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

Year 12s - where are you at with making decisions about university?

I’ve chosen my course and my university (21)
30.88%
I’ve chosen my course and shortlisted some universities (26)
38.24%
I’ve chosen my course, but not any universities (3)
4.41%
I’ve chosen my university, but not my course (3)
4.41%
I’ve shortlisted some universities, but not my course (4)
5.88%
I’m starting to consider my university options (9)
13.24%
I haven’t started thinking about university yet (1)
1.47%
I’m not planning on going to university (1)
1.47%

Watched Threads

View All