C++ :: Find Average Of 5 Grades - Lowest Number Dropped
Nov 8, 2014
This is a simple program I am building to find the average of 5 grades where the lowest grade is dropped. I created a function findLowest() which accepts the 5 grades as arguments, finds the lowest grade and returns it as "lowest". I have tried many different way to find the lowest number. Right now, I am working with if...then statements.
#include <iostream>
using namespace std;
void printMessage(); //Prototype for printMessage
void getScore(int&); //Prototype for getScore with reference variable
int findLowest(int,int,int,int,int,int &); //Prototype for findLowest with reference variable
I need to write a program that prompts the user for 10 grades and then find the average. I have that part but I need to average to not include -1. How can I tell the program to not calculate -1 into the average.
#include <iostream> using namespace std; int main() { //Declare variables float grade[10]; // 10 array slots int count; float total = 0; double average;
5. Find the deviation of each score, and display the score and its deviation.
6. Find the Standard Deviation and Display
7. How many scores are within One Standard Deviation
So I have the average down, but I am getting stuck at the part of displaying the highest and lowest score. Every time I run the program I get two giant negative numbers for both of them. I put all the scores into a .txt file and I just opened in through the program.
I have a project that I am working on and I have gotten stuck. I am getting a couple errors and would like to see how I can complete the program. Not very long of a program at that. My instructions are:
Write a program to calculate averages. Create a method named ReadData that will load a two dimensional array, named scoresArray, with the following data from a file:
Create a method named DisplayAverages that will display the emplyee number (number starting 1324, 4356 etc) and the average of the three test grades. DisplayAverages will have one argument, the scoresArray. Your output should closely resemble the following.
Round averages to one decimal place. Passing arguments is important for this program. No global variables are allowed, except for the streamReader and the streamWriter. The scoresArray must be declared in Main and passed as an argument to the methods ReadData and DisplayAverages.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using LibUtil; using System.IO; using System.Text.RegularExpressions;
[Code] ....
When I run the following just to see where I am getting I get the following error:
UsersJoeDocumentsVisual Studio 2013ProjectsCIS110Program12Program12Prog ram12Dat.txt was opened Unhandled Exception: System.IndexOutOfRangeException: Index was outside the boun ds of the array. at Program12.Program.ReadData(Double[,] scoresArray) in c:UsersJoeDocument sVisual Studio 2013ProjectsCIS110Program12Program12Program.cs:line 66 at Program12.Program.Main() in c:UsersJoeDocumentsVisual Studio 2013Proj ectsCIS110Program12Program12Program.cs:line 24 Press any key to continue . . .
What am I missing here? I believe I have passed the arguments properly, but I am unable to declair the array within the bounds of the array?
The bottom three functions do not work. Nor are the finished to the extent. I do not know how the data members are being accessed and is only giving me the last output. The overall goal of this program is to output the highest grade with student name and age, lowest grade with student name and age, and the average of all grades. The file is given and is commented out for you to see what the file looks like.
// Header Files #include <iostream> #include <fstream> using namespace std; // Global Constants const int STD_STR_LEN = 10;
An instructor needs you to write a program that will compute the final average grades in her class. There are 5 students in the class. Each student must take 2 exams and 4 quizzes as part of their final grade. The weight of each toward the final grade is as follows:
You must use arrays to store each students 3 digit ID number, exam scores and quiz scores. A multi-dimensional array is mandatory. Request from the user the information needed then output all of the information as well as the final average grade for each student.
Write a program that uses two functions; one finds the largest number and second largest number; and second function finds the average. The data, comprising of 20 different temperature values, is available on a file.
I'm having trouble, I want the inner loop to display the lowest and highest score. If I assign initial values for the high and low score, it won't always work (because if no/ all scores are above/ below my initial values...)
But without assigning initial values for highscore and lowscore, One of them will always be undefined during the first runthrough.
#include <iostream> using namespace std; const int AGRADE = 90; const int BGRADE = 80; const int CGRADE = 70; const int DGRADE = 60; int main() {
[code]....
how do i set this up so it stores a low and high score, and then compares those to each next number in the series?
#include <iostream> #include <iomanip> #include <fstream> using namespace std; // Function prototype void getScore(int& score, ifstream& inFile); void calcAverage(int s1, int s2, int s3, int s4, int s5, int lowest);
[Code] ....
The program is suppose to report back the lowest number of 5 grades in a file..then it is suppose to report the average of remaining 4 higher scores..It appears to be reporting the correct average which tells me that it is reading the file and dropping the lowest score but it does not report back the lowest score first.
What i need it to do is ask the user for a number of cases. The user will input numbers and the program should add the inputs until zero or a negative number is entered and then out put the average of those inputs. The amount of cases is pretty much how many times an average will be done. so if the amount of cases is 4. and the inputs are 1,3,(1+3/2)0 then it should output 2. and that would be ONE case, next inputs are 5,6,4,0(5+6+4/3) the output is 5 and that is case two. etc.
Here is my code:
#include <iostream> using namespace std; double avgVal(int, int); int main() { int amountOfCases; cin >> amountOfCases; int* numbers = new int[amountOfCases]; int input=0;
I have the random values down but when I try to assign randValue to another integer I get an error.I want to make an inner loop where I find 5 random number 50 times and print the average of those numbers.
I know I have the bare bones of the below, but without giving me a huge shove in the right direction can I have a poke? I have been programing for three months now. I have noticed when I do simple fun projects I learn more then what my professor assigned to me. The class is over but I want to keep building.C++ starts in one week...
I made a program that is suppose to receive 20 numbers or less and find the average, then show all numbers entered but my average does not show. It shows as 0 and a line pops up after every number returned. I am stuck and dont know how to fix the logical errors.
#include <iostream> #include <cmath> using namespace std; int main() { float num[20]; int amount_num;
The following fuction from a class is supposed to count the number less then the average of all number combined. but it does not do that, now the fun part if you change it to count the number greater then the average it works great.
void IntegerArray::countBelowAverage() { avrg=calcAverage(avg); int count=0; for(int x=0; x<100; x++) { if (list[x]<avrg)
I am currently confused on how to get the highest and lowest number from a list of 7 numbers for a File Output. Lets say i have 165 19 654 816 654 987 324. How would i get the 987 for the highest and the 19 as the lowest? Those numbers are not fixed numbers, i need to be able to input any combination of numbers and still be able to get the highest and lowest numbers from the list of 7 numbers.
I am having a problem printing out the results for my code, It is supposed to print out the largest and smallest value in the array, but keeps giving me a value not entered and I don't know why.
//This program lets the user enter 10 numbers and then display the highest and lowest number.
#include <iostream> #include<stdio.h> using namespace std; int main() { const int NUM_ENTERED = 9; int number[NUM_ENTERED], highestValue = number[0], lowestValue = number[0], count=0;