C++ :: Displaying Averages In A Table

Feb 14, 2013

I've finally been able to get my coding corrected after doing this for 5 hours and watching numerous tutorials on it... But I now need to create a table. how to create a table with dashed lines like -----------------, both vertical and horizontal.

Another issue I have is that I'm having trouble trying to get a prompt to ask the user how many programs, tests, and quizzes he/she completed with their total points. I got the basic programming done, but need a prompt asking "How many (quizzes, tests, or programs) have you completed?"

Finally, the do-while loop is driving me insane, where I have to set certain values. If it is greater than 2, then I insert formula 1, but if it is less than 2, then I insert formula 2. Whichever way it goes, the total points earned minus the two lowest scores are then calculated into an average.

Code:

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()

[code]....

The whole basis of the program is to calculate the averages of programs, tests, and quizzes done during a semester at a school. The user is asked how many of each category he/she has completed (total points earned and total points possible). All of this is then calculated into a cumulative class average in a table along with points earned and points possible for each category (along with tests and quizzes combined into one average along with individual averages).

View 2 Replies


ADVERTISEMENT

C :: Displaying Direction From A Table Of Values

Oct 1, 2014

Below, is the program I completed so far. I need to write a C program that reads in a stream of integer values, each representing an (x,y) pair on the cartesian plane. It then says I need to display the distance and direction from one point to the next. I tested it out, and it works.I need to use a conditional statement, and I'm a little confused how to display the direction(right, left, up, or down).I think I need to use an. "If" statement with my first one being something like:

If (y2 = y1) && (x2 > x1)

and I'm not sure what else to put,or if this is wrong. And with y staying the same and x increasing, the direction would be right.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
int x1, y1,x2,y2,x3, y3,x4,y4,x5,y5,x6,y6; //x and y coordinates

[Code] ....

View 1 Replies View Related

C :: Program Is Not Computing Averages From Array

Sep 23, 2013

This code is not computing the averages.. I am trying to add up all the values in the array and divide them by the number of addresses in the array

Here is the snippet of what I have do far :

//Run through all possible train combinations

Code] :

for(tl=10; tl<=max_tl; tl+=8) {
n_cars++;
num_trains=(.25*max_track)/tl;
num_people=n_cars*num_trains*4;

[Code] ....

View 10 Replies View Related

C++ :: 2D Arrays Adding Rows And Getting Averages

Apr 22, 2015

How to get my functions to work. I have to use void functions but I'm lost. I have to bring data in. An array of numbers.

8 27 33 14
81 146 305 249
412 71 226 4
144 55 97 493
133 265 788 240
380 117 88 25

The program works great until I add the computeSums or computeAvgs functions.

Code:
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
void computeSums(int fishArray[][4], int rowSum[], int colSum[]);

[Code] .....

View 4 Replies View Related

C :: Take Averages Of Whole Week And Output Print Statement

Jul 17, 2013

I wanted to take the averages of the whole week and output a print statement. I've tired few ways this like assigning "temp" a pointer, or in each if statement assigning temp to a new variable like a, b , c etc. Then adding them all up at the end and dividing by 7. My issue is I am unclear how to store the number typed for each if statement while the program is running, then have it compute the simple equation. The code in question is below:

Code:
#include <stdio.h>
int main(int argc, const char * argv[]) {

int i, j = 0, temp = 0;
for (i=1; i<=7; i++) {
j++;

[Code] ....

View 1 Replies View Related

C :: Program Fails To Show Totals / Averages

May 17, 2014

The code is supposed to display the total and averages of the data as well, but cuts off due to an error in the code. The code should also:

1)Print checks for all employees, one per page, sorted by lastname. The first check number, 100, is to be read from a company data file (see requirement 4). The border of each check is important and should not be omitted.

2)Convert the net pay to a text string for each check printed.

3)Print a reference code on each check. The reference code is obtained by combining the first letter of the lastname with all the consonants remaining after removing all vowels (a,e,i,o,u).

4)Use the same employee data found in assignment 2. Use the following company data, obtained from a text file,

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

[code]....

And here's where the program stops. URL.....

Output I'm expecting: Program to display totals and averages (worked before I turned everything into an array), now exits with error before totals/averages are displayed. Program also writes up a report.txt file that also writes this information into it, as well as using a quicksort to organize the names alphabetically, and print paychecks (all of the #BORDER, #HEADER1-8, #STUB, etc). In that check a reference code is also generated (teacher gave us code, we just had to modify for our final program as seen here)

Flow of the program: Print headings to label all of the input data we will enter soon under the categories as listed in the heading. Initialize all of our totals (in our array) to value of 0. These will be added in a loop "AddAccumulators" which takes our value for the hours, payrate, and taxes from each employee array structure and adds it to the total array. Program will write this information into the report.txt file with the HEADER line for totals, and should be displaying it in that picture. (Same for averages). After all of the data is calculated, the Reference code, Totals, Averages, and individual employee data is taken and put into printing out a Check Header and Stub.

View 10 Replies View Related

C++ :: Output Information For Three Students - Calculating Averages

Feb 14, 2015

Write a C++ program to output information for three students. The information stored in your program contains student’s first name, middle name, last name, and test score. The following shows the information for the three students, where test score is in the int type.

John Jacob Smith 78
Mary Jane Weems 82
Dave Joe Dale 61

Your program should declare three named string constants for the three students. Each constant contains the student’s first name, middle name, and last name. You may use three int variables to hold values for the three test scores. The first name, middle name, and last name of a student are then extracted using the substr() function shown in class. Your program should also compute the average (in floating-point number format) for the three test scores. The average score computed should be printed to the screen with 2 digits displayed after the decimal point.

The following shows the output from the program. Note that all the output is left-justified with 15 character positions reserved for each.

first name middlename lastname testscore average
John Jacob Smith 78 73.67
Mary Jane Weems 82 73.67
Dave Joe Dale 61 73.67

View 1 Replies View Related

Visual C++ :: Program Fails To Show Totals / Averages

May 17, 2014

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

[Code]....

I know it has to do with the array, and I've tried over and over again to fix my issue and nothing has worked thus far.

View 3 Replies View Related

C++ :: Hash Table Program - Sorting Pointer Table After All Of Values Entered

Nov 19, 2013

I am having an issue with my sort function. This is one part of the Hash table program. The main issue is that I am trying to sort the pointer table after all of the values have been entered. The ptr_sort function is not a class function and so I am therefore unable to use the class variables psize and pTable. Is there another way I should be trying this? it is a Vector should I use the sort() function from the vector class in STL?

#include "/home/onyuksel/courses/340/progs/13f/p9/util9.h"
#include "/home/onyuksel/courses/340/progs/13f/p9/hTable.h"

#ifndef H_TABLE1
#define H_TABLE1
void ptr_sort ( );

[Code] ....

View 1 Replies View Related

C++ :: Truth Table Generator - If User Enters String Of Boolean Algebra It Will Output Table

Jan 25, 2013

If a user enters a string of boolean algebra it will ouput the table.

I have input parsing, cycling through the combinations, and outputing working. However once i parse the input I am not sure what to do with it. I have thought of having it write the parsed input to a new file as a function and then use that function, but that seems bad.

How to dynamically create the function, how to implement it.

BTW This is a console function, if that changes anything.

View 2 Replies View Related

C# :: Lookup Non-existent Rows In MySQL Table And Then Update Another Table

Dec 15, 2014

I have written an SQL statement that would:

1) Count the number of rows in the table booking that are open and where the booking.postcode is "MK",

2) Take a note of the plot (in booking.plot_id), and then update the table plot.jobs with the value count.

For example running the SQL query when booking table has the following rows:

Would see the following highlighted values in plot.jobs being updated to 1:

I managed to resolve it with this code so far (note I am using Connector/Net):

public void RefreshPlot(){
string query =
"SELECT Count(*) AS count, plot_id FROM booking WHERE postcode='MK' AND status='open' GROUP BY plot_id";
var cmd = new MySqlCommand(query, _connection);
var da = new MySqlDataAdapter(cmd);
var dtCounts = new DataTable();
da.Fill(dtCounts);

[code]....

Currently, my code only checks for existing rows in the booking table and updates the plot table. However if the row gets deleted in the booking, then the changes are not reflected in the plot table.

Example: If we delete the row with plot.id=1 and plot.plot_id=4, then booking.plot_id should go back to being 0, if it was initially 1. At the moment, it doesn't. How would I update my SQL statement to better reflect this? In a sense, it should check for "non-existent" rows, i.e. the impact that the row plot.plot_id=4 & plot.id=1 has on booking.plot_id when deleted?

View 6 Replies View Related

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 Sharp :: Copy Data Table To MySQL Table

Mar 25, 2013

I have a C# .NET Application which get data from QuickBooks via the ODBC Driver and save the result to C# data table. So, I want to transfer this data table to a mysql table on my own server. That's the code I use:
 
using System.IO;
using MySql.Data.MySqlClient;
//Add mysql dll on the .NET Tab in Project's references  
string connStr = "DSN=QBTest;";  
            string myServerAddress = "192.168.0.243";
            string myDataBase = "CostTest";

[Code] ....

View 2 Replies View Related

C++ :: Program That Takes Baseball Players Statistics And Display Averages - Function Division

Oct 10, 2013

I was required to write a program that takes a baseball players statistics and displays there averages. I was required to make 3 function in the file to perform this tasks. my problem I am having a division problem in the SLG function. My compiler does not require the system ("PAUSE"); command.

OUTPUT
The player's batting average is: 0.347
The player's on-base percentage is: 0.375
The player's slugging percentage is:
(test)AB = 101
(test)Tot Base = 58
0.000

Code:
/* Batting Average Program
file: batavg1CPP.cpp
Glossary of abbreviations:
BA = batting average
PA = plate appearances
H = hits
BB = bases on balls (walks)

[Code] ....

View 3 Replies View Related

C# :: Use Table Adapter With Textboxes To Edit SQL Table?

Mar 8, 2015

I am a bit stumped with trying to write some code to get the tableadapter/binding source to "update" a current 'user' to the table.

I have the insert/delete methods working fine, but it's the updating that has got me screwed up.

Example of insert.

try
{
personTableAdapter.Insert(tFirstName.Text, tSurname.Text, Convert.ToDateTime(tDoB.Text), tPhone.Text, tAdd1.Text, tAdd2.Text, tSuburb.Text, tState.Text, tPostcode.Text, TeacherType.Text);
teacherTableAdapter.Insert(Convert.ToInt32(tTID1.Text), tRegNo.Text, tPassword.Text);

[Code]....

I also tried to do the updated string/original string with the tableadapter.update, but that didn't work either.

View 7 Replies View Related

C++ :: Displaying Contents Of A Map

Jul 20, 2013

I'm trying to display the contents of this map. I'm having some trouble where the program ceasing to display after "Index Contents."(lines 33 -40) If I move the display for loop right where I'm inserting the values (line 52) into the map I get output. I'm not sure where bug is.

#include <iostream>
#include <fstream>
#include <vector>
#include <sstream>
#include <regex>
#include <iterator>
#include <algorithm>
#include <string>
#include <map>

using namespace std;
typedef istream_iterator<string> isIterator;
typedef map<string, string> indexMap;

[Code] ....

View 1 Replies View Related

C/C++ :: Output Displaying As 0?

Mar 5, 2015

I am trying to write a c program to convert centimeters to inches and then to feet. I have most of the code written but not sure how to debug it. I keep getting "0" as all of my output.

#include <stdio.h>
// Main Function
int main(void)

[Code]....

View 2 Replies View Related

C++ :: Displaying 2D Array

Jan 6, 2012

I got assignment at my school to display 2D array like this:

This is default array:

1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16

Now I have to print the default array like this:

1 2 6 7
3 5 8 13
4 9 12 14
10 11 15 16

I have tried some codes to do it myself but i had no success.

View 1 Replies View Related

C++ :: Output Displaying Out Of The Screen

Feb 11, 2014

I have turbo c++ on windows xp SP2.....whenever i compile my code in turbo c++ i am getting output outside the screen.....but when i used code::block....i get the correct output...fits to screen ...

View 7 Replies View Related

C++ :: Displaying Image From Stream

Feb 24, 2013

I'm trying to display an image from a stream data. But there is no image when getting image::from stream.

It's my source code:

Code:
IStream* pstream = NULL;
if(SUCCEEDED(CreateStreamOnHGlobal(NULL, TRUE, &pstream))) {
ULONG lreal = 0;
pstream->Write(chIncomingDataBuffer, iEnd, &lreal );

[Code]...

There is no image from data.

View 5 Replies View Related

C :: Displaying Proper Value With Arrays?

Jun 30, 2014

I'm currently working on a temperature conversion program using arrays / pointers as practice.

I will post the code below, its quite a bit lengthy and its also incomplete. Everything was going smoothly and I continually test my code as I write to completion, then I ran into a small road block.

My problem here is regarding the output from the first if statement in main. When I enter a value to convert from F to C. It successfully converts the first value I enter, but any other value after the first one during the loop in the first if statement, just shows long numbers of all sorts.

The output looks like this:

I kept checking the logic behind what I did, and for me it seems to be correct. Here is the code:

Code:

#include <stdio.h>
#define array_size 5
#define NEWLINE printf("
")

[Code].....

View 4 Replies View Related

C++ :: Merging Two Arrays And Displaying Them Together In End

Oct 7, 2014

merging two arrays together and displaying them together in the end. However, I do not know how to start the merge function.

#include <iostream>
#include <assert.h>
using namespace std;
struct Array {
int* array; // point to the dynamically allocated array
}

[code]....

View 1 Replies View Related

C++ :: Displaying Inverted Pyramid

Oct 7, 2013

The user will enter the number of '*'s on the 1st row (ntop) and then the number of rows forming the trapezoid (nrows). (using <iostream>, cout)

For instance, an inverted trapezoid with 7 '*"s in the 1st row and 3 rows forming the inverted trapezoid looks like:

for (i = nrows; i >= 1; i--) {
for (j = 0; j >= nrows; j++) {
cout << " ";
} for (k=ntop; k >= 2; k--) {
cout << "*";
} }

The output is just blank as of now.

View 3 Replies View Related

C++ :: Displaying Most Profitable Day Of Week

May 9, 2014

I am trying write a void function which will tally up the totals for each day and then display the most profitable day of the week.

#include "stdafx.h"
#include <iostream>
using namespace std;
#include <iomanip>
#include <string>
#include <fstream>
struct Menu_Items {
string Item;
double Price;

[Code] .....

The void function must pass as a parameter a pointer to the first element of the Orders_Placed array. I have attempted to write this. But I do not think I am even close. I need to have 7 double variables that hold the totals for each day of the week. Those are the MonTotals , TueTotals , etc....

How do I get these totals for each day?

How do I fix this void function so that is displays the most profitable day. Also, would the function call be Biggest_Profit(Orders_Placed)??

The GetPrice function provides the price given a menu item.

View 1 Replies View Related

C++ :: Displaying Commas In Loop?

Oct 6, 2013

If the number 4 is entered, the output should be the following:

1: 1
2: 1, 2
3: 1, 3
4: 1, 2, 4,

My output, however, is different but I know its an error with the comma.f

1: 1, , ,
2: 1, 2, ,
3: 1, , 3,
4: 1, 2, , 4

Here is my code:

#include <iostream>
using namespace std;
int main()
{

[Code].....

View 1 Replies View Related

C++ :: Why Is Structure Member Not Displaying

Jan 7, 2015

I have started working with structures so here's a side project from my text book. It's purpose is fairly simple; it asks for the sales of each quarter of the year from 4 different divisions and then calculates the average quarterly sales and total annual sales and finally displays all the data. My problem is that in the function "displayCompanyInfo" the statement

std::cout << "Division " << R.division_name << std::endl;
does not display the name of the division. With that in mind here is the code:
#include <iostream>
#include <string>
struct CompanyInfo
{

[Code]....

As you can see the last part of the output has statements that say "Division" however they do not say the name of the division afterwards. I don't understand why that is?

View 2 Replies View Related







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