C++ :: Calculating High / Low And Average For Grades

Feb 6, 2015

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;

[Code] .....

View 5 Replies


ADVERTISEMENT

C# :: Calculating Averages - Display Employee Number And Average Of Three Test Grades

May 3, 2015

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:

132475.889.392.3
435686.383.498.3
479090.177.376.9
839373.976.389.3
556397.378.478.9
832987.365.377.2
271767.989.379.3

ReadData will have one argument, the scoresArray.

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.

Student #Test1Test2Test3Average
132475.889.392.385.8
etc, etc

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?

View 2 Replies View Related

C++ :: Program That Prompts User For 10 Grades And Then Find Average

Feb 24, 2015

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;

[code].....

View 1 Replies View Related

C++ :: Program That Compute Final Average Grades Of Class

Jan 28, 2013

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:

Exam 1 – 30%
Exam 2 – 30% Quiz 1 – 10%
Quiz 2 – 10%
Quiz 3 – 10%
Quiz 4 – 10%

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.

View 1 Replies View Related

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

[Code] ....

View 2 Replies View Related

C/C++ :: Calculating Grade And Average?

Dec 10, 2014

Write a program to compute average grades for a course. The course records are in a single file and are organized according to the following format: Each line contains a student's first name, then one space, then the student's last name, then one space, then some number of quiz scores that, if they exist, are separated by one space. Each student will have zero to ten scores, and each score is an integer not greater than 100. Your program will read data from this file and write its output to a second file. The data in the output file will be nearly the same as the data in the input file except that you will print the names as last_name, first_name and there will be one additional number at the end of each line: the average of the student's ten quiz scores.

The output file must be formatted such that first and last names appear together in a left justified column that is 20 characters wide where the last name comes first, then a comma and a space and then the first name. Use your read string function to read each name separately and then put them together into a larger correctly formatted string before trying to output them. Each quiz score should be listed in a right justified column that is 4 characters wide, and the average should appear in its own right justified column that is 10 characters wide.

Note that if a student has fewer than 10 scores, the average is still the sum of the quiz scores divided by 10; these students are assumed to have missed one or more of the quizzes. The output file should contain a line (or lines) at the beginning of the file providing appropriate column headings.

This is how much I have so far:

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
char* read_string(char* buffer, int max_size, FILE* fp);
int main(int argc, char *argv[]) {
FILE *fp_input, *fp_output;

[code]....

View 7 Replies View Related

C++ :: Calculating Average Using Two Different Functions

Mar 16, 2013

When I compile my code with g++ I get the error: constructor, destructure or type conversion missing before sum.

int sum(int,int);
void sum(int,int,int&);
main()
sum (v) // This is the line that the compiler is reporting the error occurs.
answer sum()
int main(){
int a=1;
int b=2;
int sum;

[Code] ....

View 12 Replies View Related

C# :: Calculating Average Of Array And Output

May 3, 2015

Now this issue is about calculating the average of numbers and displaying it in the out put.

The following numbers is what I have read in from a file. There are 7 lines all the same format, just different values of course.

132475.889.392.3
435686.383.498.3

The output will need to look like:

Student #Test1Test2Test3Average
132475.889.392.385.8
435686.383.498.389.3

My program thus far is: (omitted code to shorten post and remove irrelevant information.

I don't know if it is because I have been working on other things and forgot how to proceed with the calculations and display, but I am just stuck. I'm not sure how to have the program read the numbers from columns 2 through 5 and then divide by 3. As you can see in my DisplayAverages() method I should have the ConsoleWrite and WriteLines done properly.

static void Main()
{
double[,] scoresArray = new double[7,4];
LoadFile();
ReadData(scoresArray);

[Code]....

Should read columns 2-4 and then display the average in column 5.

View 5 Replies View Related

C :: Print Correct Normalized Value / Average And Values Above Average

Nov 14, 2013

I must write a function that has a one dimensional double array and the number of values in the array as its arguments. Normalize the values. I must also print the maximum, minimum, average and numbers of values above the average in the array.

The equation that computes the normalized value from a value x is:

Normalized x= (x-min(array))/(max(array)-min(array))

My code does not print the correct normalized value, average and values above average.

Code:
#include <stdio.h>
int findMax( double array1[], int num_elements) // This function computes the maximum value of the array
{
int i, max=-32000;
for (i=0; i<num_elements; i++)

[Code] .....

View 5 Replies View Related

C++ :: Average Negative / Positive Numbers And Total Average?

Nov 18, 2013

I am trying to average the negative numbers and positive number and of course the total average.

This will read in a list of n values, where n is not known ahead of time. The number of values read into the array will be saved in n.

vector<int> readList() {
std::vector<int> result;
ifstream inFile;
inFile.open("setA.txt");
for (int x; inFile >> x; ) {
result.push_back(x);

[code]....

array is a one-dimensional array of integers and n is the number of elements in that array that contain valid data values. Both of these are input parameters to the function. The function must calculate 1) the average of the n integers in array, storing the result in ave; 2) the average of the positive numbers (> 0), storing the result in avePos, and 3) the average of the negative numbers (< 0), storing the result in aveNeg.

void avgs (std::vector &array, int &ave, int &avePos, int &aveNeg) {
int sum = 0, pos_sum = 0, neg_sum = 0, pos_count = 0, neg_count = 0;
for (auto i : array) {
sum += i;
if (i > 0) { pos_sum += i; ++pos_count; }

[code]....

View 1 Replies View Related

C# :: Nickname Won't Appear On High Score

Mar 28, 2015

I've made a game and a dialogbox to show up asking to enter a nickname.

The problem is After entering the nickname, it won't show on the highscore list below (textbox)

Where can the problem be? Below is my code:

private void btnPlay_Click(object sender, EventArgs e) {
if (txtName.Text != "") {
Settings.Name = txtName.Text.ToString();

[Code] .....

View 5 Replies View Related

C++ :: How To Declare High Order Vectors

Sep 21, 2013

I suspect that C++11 would make it possible to declare high rank vectors such as Code: int N = 15; // chosen arbitrary rank vector<vector<vector<...<vector<double>>>>..> vec; // N layers of nested vectors Is there a way to declare such a vector of rank N (given a fixed integer rank N)?

Heuristically I would like to write the declaration like this: Code:

vector<double> A;
vector<A> vec[0];
for(int i=1; i<N; i++)
{
vector<vec[i-1]> vec[i];
} Is there a way to use the new variadic templates to make this work?

View 9 Replies View Related

C :: Using Variable Names When Calling MC PIN High Or Low

Feb 9, 2013

I haven't tried to run my program yet, but maybe I will save some trouble if I ask this question first.I am using MC PIC16F690, and I could make a pin high or low by writing RCx = 1 or 0, where x is the pin in the C port. However, I want to use the counter variable from a for() loop as the pin number. Will RC(variablename) = 1 work, or is there another syntax?

View 2 Replies View Related

Visual C++ :: CPP High Frequency Trading

Jul 15, 2014

I have taken a keen interest in writing trading programs. I have some Python background, a little C# but no C++.

The example below was provided in a book on HFT and I would love to see how the results look. I was hoping that I would just compile it and away you go!

That didn't happen. To start with the author listed this as a function, so I converted it to a main program. Still having issues with my path and where to see the output. Here it is..

Code

void HFT_AvellanedaStoikov() {
FILE* fin, *fout;
double lambda_a, lambda_b, d_lambda_a, d_lambda_b;
int hh = 0, mm = 0, ss, nb = 0, na = 0, prevnb = 0, prevna = 0, prevm = 0;
double bid, ask, prevbid = 0, prevask = 0;
char * p1, *p2, buffer[1024], fname[512];

[Code] .....

Here is some data:

14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
.... and so on ....

View 3 Replies View Related

C++ :: Structures - Keeping High Scores Of Users

Jun 1, 2013

Write a program that allows a user to enter high scores of a game, keeping tracking of the name of the user and the score. Add the ability to show the highest score for each user, all scores for a particular user, all scores from all users, and the list of users.

This is the program I am trying to write, however I am having difficulty storing the users name and high score, I know I need to store an array for the score but getting confused because of the structure. (By the way I have to use structures as it is a problem from the structures chapter of the ebook I am doing). Below is my code so far. .

Code:

#include <iostream>
#include <string>
using namespace std;
struct highScore
{
string user;
int score;
int highestScore;
int allScores;

[Code]...

View 9 Replies View Related

C++ :: How To Install High Precision Arithmetic Library

Jan 12, 2013

One of my programs I recently created, needs higher precision then what doubles can provide. So I am wondering how I install a library like this [URL] .... I don't quite understand exactly how to install them. Im using visual studio 2012 ultimate right now!

View 3 Replies View Related

C++ :: QLabels And High Speed Updating Causes Crash

Jun 26, 2014

On a project I'm working on, I need to update many QLabels very quickly. Each label needs to be updated at about 20 to 50 hertz and there can be over 50 labels at any given time. The problem I'm having is after running the program for about a minute, the labels freeze and the whole program crashes about 10 seconds later. If I comment out the setText() and setNum() calls and reroute the outputs to the console, it runs fine and never crashes. Why does calling SetText() and setNum() so quickly cause the program to crash and how can I prevent this?

View 5 Replies View Related

C# :: High RAM Usage On Postback Caused By Datatable

Dec 23, 2014

I basically have a listbox that has postcode areas i.e : AE,CW,GU etc etc.

The user selects this and then a postback occurs - an sql statement is builts and a database query operation is performed and the results are returned to a datatable called tempdata.

So far so good. I then need to loop through this datatable and copy the records to my main viewstate datatable which is the datasource for google maps api.

DataTable tempstore = GetData(querystring, "");
//check tempstore has rows otherwise add defaultcust as default otherwise map will be blank
if (tempstore.Rows.Count == 0)
{

[Code].....

So my main datatable can grow and grow as users add more postcodes. However when it gets to around 500 rows or so I get a huge memory spike only on postback and then it settles back down.

My ram usage goes from 2gb to 3gb and if even more postcodes is selected it maxes the memory and crashes my pc.

If I remove the:

dtpc.Importrow(row);

the memory spike goes completely, obviously because the main datatable has no rows. I thought you only run into memory issues when you have thousands of rows?

View 1 Replies View Related

C++ :: Create Symbol Table For High Level Language?

Jan 21, 2013

How to create a symbol table for an assembly language and high level language in c++?

View 1 Replies View Related

C# :: Generate Prime Numbers With Considerably High Upper Limit?

Aug 30, 2014

I was investigating for the first time how to generate prime numbers with a considerably high upper limit, around 10^6 or so. I read about sieve's algorithm and tried to implement it using c#, as I had previously brute forced the generation. In Sieve's algorithm, instead of marking the values that were not prime I simply eliminated them, but I don't think that would make any difference. The issue is that my implementation of sieve's algorithm must be wrong, as when I establish the limit as 10^5 I get the following output:

Brute force:
Computation time: 00:00:00.0643539
Sieve's algorithm:
Computation time: 00:00:20:6934223

I have already checked that their generation of primes is correct, but I do not know why one is significantly slower than the other. Here is my code.

using System;
using System.Collections.Generic;
using System.Linq;

[Code].....

View 5 Replies View Related

C# :: How To Manually Control The Temperature Of High Power Leds Using PID Controller

Mar 20, 2015

how to manually control the temperature of High Power Leds using PID controller. I have two GUIs,one reads the temperature from the Led while the second is used to ON/OFF the Leds and at the same time controls the Led brightness using slider control.The GUI that reads the temperature has a PID controller application on it.The output from this controller is what i want to use to increase or decrease the Led brightness which invariable changes the Led temperature.How to go about using this PID controller to control the Led brightness is what i have not been able to grasp well.The slider on the GUI is scaled from 0% to 100%.My thinking is that the output from the controller should be in percentage which will make me to adjust the slider accordingly.My question is that will this type of arrangment produce an output that will efficiently control the Led brightness. how to accomplish that. Attached to this post is a modified code of a tutorial on PID controller which i found on the net. a tutorial on how to develop a graph. i wish to display the Setpoint,Process value and the output value on a graph.

View 2 Replies View Related

C++ :: Student Grades Do Not Print?

Mar 26, 2013

//******************************************************************************
// GradeCalculator.cpp
// Input: Student Grades in Each Category
// Output: Final Grade, Numerical Grade, Witty Comment
// Final Grade Calculator
// This program calculates a final grade using a formula, assigns a
// corresponding letter grade, and outputs a "witty" comment to the user.
//******************************************************************************

#include <iostream>
#include <fstream> // For file I/O
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;

// Declare function prototypes
void OpenFiles(ifstream&, ofstream&);

[Code] .....

View 1 Replies View Related

Visual C++ :: How To Reduce High CPU Usage Caused By Receiver Thread Of CAN Messages

Feb 13, 2013

I am writing a program which handles the CAN messages Received from BUS.My code is taking almost 60% of CPU usage.

View 14 Replies View Related

C++ :: Grade Book - Using Vector To Get The Grades

Sep 15, 2013

I am trying to make a grade book and using a vector to get the grades. I am getting errors all over and I figured this would happen because this is the first time I ever used vectors.

Code:
#ifndef ___2B__Homework__LetterGrade__
#define ___2B__Homework__LetterGrade__

#include <iostream>
#include <vector>

[Code] .....

View 12 Replies View Related

C++ :: Struct - Getting Grades Of The File Sorted

Jul 21, 2014

My code has no errors. I'm just having problems with getting the grades of the file sorted. grades is not a struct, but is a int inside struct School. Below is what I;m having problems with(this is just the code I started working with,I made a few changes but it didn't work,I have no clue)

void selectionSortG() {
Students min;
int key;
for (int i = 0; i < size; i++){
min = student[i];
key = i;
for (int k = i; k < size; k++)

[Code] ....

View 2 Replies View Related

C++ :: Arrays - Determine Grades At The End Of Semester

Jul 18, 2013

Write a C++ program that can be used to determine grades at the end of the semester. For each student, who is identified by an integer number between 1 and 60, four examination grades must be kept. Additionally, two final grade averages must be computed. The first grade average is simply the average of all four grades. The second grade average is computed by weighting the four grades as follows: the first grade gets a weight of 0.2, the second grade gets a weight of 0.3, the third grade a weight of 0.3, an the fourth grade a weight of 0.2; that is computed as:

0.3*grade1 + 0.2*grade2 + 0.2*grade3 + 0.3*grade4

Using this info, you are to construct a 60X7 two dimensional array, in which the first column used for the student number, the next four columns for the grades, and the last two columns for the computed final grades. The output of the program should be a display of the data in the completed array.

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved