after reading scores from file I need to find the lowest score, add all scores together, calculate final score, inside the for loop. I am lost and could use some help. Here is my code so far.
for (index = 1; index < 6; index++)
{
//Get score from input file
fin2 >> scores;
//Output score to outfile, fout
fout << "Score #" << index << ":" << setw(10) << scores << endl;
if (scores < lowScore)
{
lowScore = scores;
}
}
//Calculate scores total
scores += scores;
//Subtract lowest score from scores total
total = scores - lowScore;
//Calculate final score
finalScore = total / (5 - 1);
//Move read pointer
fin2.ignore(100, '\n');
//Get name from input file
getline(fin2, name, '#');
#include <iostream>
#include <stdlib.h> /* srand, rand */
#include <time.h> /* time */
#include <climits> // for int max
int main(int argc, constchar * argv[]) {
int numbers[100] = {0};
srand (time(NULL));
// making random number array ///
for (int i = 0; i < 100; i++) {
numbers[i] = rand()%1000;
std::cout << "Number " << i+1 <<". " << numbers[i] << std::endl;
}
// finding lowest nubmer //
int lowestNumber = INT_MAX;
int lowestPostion = 0;
for (int i ; i < 100; i++) {
if (numbers[i] < lowestNumber) {
lowestNumber = numbers[i];
lowestPostion = i;
}
}
std::cout << "The lowest number is at postion ." << lowestPostion+1 << " and its value is " << lowestNumber <<"." << std::endl;
return 0;
}
Number 1. 144
Number 2. 977
Number 3. 711
Number 4. 341
Number 5. 781
Number 6. 32
Number 7. 143
Number 8. 998
Number 9. 294
Number 10. 266
Number 11. 491
Number 12. 887
Number 13. 521
Number 14. 247
Number 15. 106
Number 16. 909
Number 17. 42
Number 18. 716
Number 19. 531
Number 20. 199
Number 21. 194
Number 22. 874
Number 23. 552
Number 24. 692
Number 25. 731
Number 26. 407
Number 27. 67
Number 28. 63
Number 29. 145
Number 30. 873
Number 31. 494
Number 32. 966
Number 33. 983
Number 34. 30
Number 35. 183
Number 36. 279
Number 37. 515
Number 38. 519
Number 39. 656
Number 40. 419
Number 41. 226
Number 42. 693
Number 43. 197
Number 44. 956
Number 45. 981
Number 46. 840
Number 47. 765
Number 48. 143
Number 49. 238
Number 50. 198
Number 51. 462
Number 52. 260
Number 53. 366
Number 54. 316
Number 55. 963
Number 56. 543
Number 57. 841
Number 58. 809
Number 59. 743
Number 60. 154
Number 61. 88
Number 62. 406
Number 63. 392
Number 64. 774
Number 65. 840
Number 66. 892
Number 67. 382
Number 68. 753
Number 69. 654
Number 70. 928
Number 71. 582
Number 72. 406
Number 73. 1
Number 74. 714
Number 75. 831
Number 76. 82
Number 77. 152
Number 78. 796
Number 79. 152
Number 80. 642
Number 81. 676
Number 82. 77
Number 83. 378
Number 84. 737
Number 85. 287
Number 86. 132
Number 87. 683
Number 88. 217
Number 89. 832
Number 90. 563
Number 91. 161
Number 92. 481
Number 93. 656
Number 94. 862
Number 95. 396
Number 96. 715
Number 97. 324
Number 98. 289
Number 99. 733
Number 100. 463
The lowest number is at postion .73 and its value is 1.