C++ :: Use Functions In A Program To Show Names And Grades

May 19, 2013

how to use functions in a program to show the names and grades of students, their average, total, highest and lowest grades.

View 1 Replies


ADVERTISEMENT

C++ :: How To Sort Names And Grades From Highest To Lowest

Oct 28, 2014

How do I sort names and grades in C from highest to lowest?

John 91
Joseph 92
Mary 93
Jake 94

Sorted Scores from highest to lowest

Jake 94
Mary 93
Joseph 92
John 91

View 2 Replies View Related

C++ :: Show Pictures Randomly Without Listing Names Of Files

Apr 22, 2014

i was making a quiz and i want to show some pictures as questions to recognize i but i don't know how to show different pictures without listing the names of the files in the program, i mean i will generate a random no and based on the no the file name should change in the code like if the no is 1 it should find '1.jpg' and show it and if the no next time comes 23 then it should find '23.jpg'.

View 9 Replies View Related

C++ :: Call Only Those Functions Whose Names Are Written In Disk File

May 26, 2013

Here is a working C++ program and its output that reads the names of a certain number of functions whose names are written in a disk file that provides the control parameters in a near-real time fashion. Based on this information, the program calls those functions whose names were given in this text file as parameters. The method I have used is to build a map of functions that connects the names of the functions to the actual functions. Once this map is created, then it is very easy to iterate in such a way that only those selected functions are called.

So far this is working well, and it makes the logic of the code easier because ultimately there will be a large inventory of functions (probably hundreds of functions), and this way of pre-building a map of functions avoids writing hundreds of if statements in the code. Of course, pre-building this reusable map in the background is still equivalent to writing that many if statements, but at least it makes the code very compact and much more automatic, since it is done only once.

But I now have a related question: In this case (when the selected subset of functions to call is given as incoming data as in this example), does C++ make it possible to avoid using maps of functions, by directly applying the string variable that holds the name of the function in order to call the original function immediately For instance, if a string variable s = "MyFunction", then is there a more direct way of using this string as if it were the actual function whose name is spelled exactly in that way? This would make the code even more compact.

Here is the sample test code for the map of functions, and its output:

First of all here is the text file "FileForNamesOfFunctions.TXT" that contains the part of the "data", which is the set of functions select from from the inventory and only call these:

Code:
function2
function3
function5 And here is the C++ code that uses this "data":

Code:
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

[Code] ....

View 8 Replies View Related

C++ :: Writing A Program To Calculate Grades

Apr 22, 2014

Writing a program to calculate grades... My algorithm is long, so I only posted the part that gives me trouble. When classes== 1,2,4, or 5, the program runs fine. but it terminates when classes == 3.

if (classes==3) {
do {
cout<<"Enter the Letter grade for 1st class. (USE CAPS)"<<endl;
cin>>grade1;

[Code].....

View 3 Replies View Related

C++ :: Making Namespace - Show Variables And Functions Into Compact Area

Sep 13, 2013

I know how to make a namespace i just want to know why someone would. because it just seems like a way to show a bunch of variables and functions into a compact area.

View 3 Replies View Related

C++ :: Finding Program That Calculates Student Grades?

Jun 7, 2013

I have to make a program that reads two student grades, the average of the two has to be 6, if you can not take an average of 6, will make a third test and calculate a new average.

I'm not getting the new display medium, without repeating the approved and disapproved?

// TRABAV2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[]) {

[code]....

View 1 Replies View Related

C++ :: Program Compiles But Refuses To Print Out Char Grades?

Nov 10, 2014

#include <fstream>
#include <ostream>
#include <iostream>
#include <iomanip>

using namespace std;

const int NAMESIZE = 15;
const int MAXRECORDS = 50;

[Code] ....

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++ :: Write Program That Asks User To Enter Student Grades?

Jan 21, 2014

Write a program that asks the user to enter a student’s grades on four exams. The program should display the four grades and the average of the four grades,rounded to the nearest tenth. To add the grades, use a variable called total_grade, which you should initialize to zero.As the program prompts for and obtains each grade, add the grade to total_grade using the += operator.

View 3 Replies View Related

C :: Program That Grades A True / False Quiz - Data Available In Text File

Oct 14, 2014

You are to write a C program that grades a true-false quiz. The quiz data will be available in a text file; here is an example:

Quiz #8 (09/22/14) (corrected version)
TTFTTFTFTF
0080 TTFTTFTFTF
0340 TTFTFFTFTF

The first line in the data file is a comment that you may assume can be up to 80 charac- ters long; it cannot be blank. The second line contains the answer key for the 10-question true-false quiz. The following lines in the data file contain a student's id number in column 1 followed by their answers for the quiz in column 2. A 0 (zero) on a line by itself indicates that there are no more students to process.

Write a program that first reads in (from standard input; more on this in a moment) the comment line and answer key as strings followed by each student's data. Store the student's id numbers in an array. You are to "grade" each student's quiz using the key provided fol- lowed by recording their scores (in a second array) in order to be able to print them out later. You do not need to use an array of strings or characters in your program. Write your program allowing for up to 100 students, and you may assume that at least 1 student will have taken the quiz.

You should create test data text files and provide the data to your program using redirection from the command line (see the sample run below). Your program should output the number of students who took the quiz, the average score, the best score, and a table showing each student's id, score, and grade. The formatting, spacing, and labels in your output should 1 match the sample run below exactly.

Your program should determine each student's grade as follows: if the score is equal to the best score b or b−1, give an A. If it is b−2, award a B. Give C's for any score that is equal to b−3 or b−4, a D for b−5 and an F for all others.

Alright So I'm just stuck at comparing the key answer with student answer here is my code comparing one student's answer with the answer key . is that right ?? One more thing for some reason when i try to print answer[0] the result is nothing why is that

Code:
#include<stdio.h>
int main(void) {
char comment[80];
char answer [10];
char studentans [10];
int n=0,i=0,x=0;
int ID[10];

[Code] .....

View 1 Replies View Related

C :: Program To Calculate Students Grades From Input File And Write To Output File

Aug 29, 2014

One of my class assignments is to create a program that receive a .txt file containing a students name and their grades as follows:

John K. 99, 87, 57, 89, 90, 95
Amanda B. Jones 100, 88, 76, 99, 86, 92
etc..

The number of students is unknown until run time. You have to take those grades and average them weighing the first (4) at 10% a piece and the last (2) at 30% each.

Then return an output file with the students name and their letter grade A,B,C,D,F based on their computed score. In addition, on screen it needs to display the average scores for each Q1, Q2, etc. as well as the minimum and maximum for each test on the screen. I am having a hard time in assigning the scores to a variable so that they can then be computed as an average and then used to determine a letter grade. I have begun to write the code and am a bit stuck..here's what I have so far:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

[Code]....

View 2 Replies View Related

C/C++ :: Program To Compute Students Grades From File And Write Them To File?

Aug 31, 2014

We have to write a program that reads an input file containing data in the form:

Martha J, 80, 90, 90, 100, 89, 99, 85
Anna Smith, 65, 72, 77, 68, 62, 70, 65
Bill Gates, 60, 54, 89, 62, 65, 60, 50
...etc...

and then use that information to determine their letter grade and write that information to a .txt file. I have been able to successfully pass that information to a function to determine their letter grade and have been able to successfully compute their letter grade. However, I can get this information to successfully post within the *computeGrade () function. Yet, I don't know how to pass this information back to the main() on a student by student basis so that I can open a new .txt file and write just their name and letter grade to it.

Another issue I'm having is when it comes to computing the averages of the class. Each score is either a quiz (there are 4), a midterm (there are 2) or a final (there is 1). I'm a little stuck on how to pass say all of the quiz 1 grades as one entity to the function averagesminmax(). Is there a way to compile each of the grades for a specific quiz or midterm as one array and pass that to the function to then do the computation. Also we need the min and max so again from compiling the grades of a particular quiz or exam together as one.

Here's the code that I have so far.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
const char *computeGrade();
int averagesminmax();
int main() {
char fName[20];
char lName[20];

[code]....

Do I need to re-read the input file and assign them to different variables?

Here's a sample of the output so far:

Enter input .txt file name
Graded
Thui Bhu, 91, A
Ariana B. Smith, 96, A
Emily Gonzales, 83, B
Jennifer L, 89, B
Maria Jones, 67, D
Bill Gates, 55, F
Escobar Morris, 78, C
Anne Latner, 88, B
Program ended with exit code: 0

Also in my output file, the only thing that it prints will be the first name of whatever the last student in the input file list is.

View 2 Replies View Related

C++ :: Delete Specified Names From A List Of Store Names?

Feb 10, 2013

i have a vector of stores. i would like to delete the specified choice(store) from the list. Here is what i have but my erase statement is wrong and wont compile.

void Store::deleteSpecifiedStoreFromList(string choice) {
for (int i = 0; i < this->stores.size(); i++) {
if(this->stores[i].getStoreNames() == choice) {
this->stores.erase( std::remove_if( this->stores.begin(), this->stores.end(), choice ), this->stores.end() );
}
}
}

View 4 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++ ::  program That Reads Into String Object A Name With Three Blanks Between First And Last Names

Oct 4, 2014

" Write a program that reads into a string object a name with three blanks between the first and last names. Then extract the first and last names and store them in separate string objects. Write a function subprogram that displays its string argument two times. Call this function display the first name for times and then to display the last name six times."

I completed coding the first part of this task with the strings and combining strings together. However, i have having trouble with the other half of this task. It begins from "Write a function subprogram to display the last name six times." This is where i have so far --

#include <iostream>
#include <string>
using namespace std;
int main()
{
// Defining the strings

string firstname, lastname;
string wholename;
string greet = " Hi ";

[code]....

View 2 Replies View Related

C++ :: Adding Employee Names In Function Arranged Program

May 13, 2014

The program that I have written below is working. It calculates a number of payroll type variables and most recently the net pay average (All this is working 100%).

My problem is that I need to add first and last employee names to the program but every time I do this I end up ruining the working program. I've successfully added first and last names to similar programs in the past(ones that make use of an array and while loop) but never to a program that uses functions (I always have problems doing this).

My question is what codes do I use to add a first and last name variable and where do I put those codes within my program so it runs/displays correctly.

I think the coding must be similar to what I've used in the past charr and of course firstname[i] and lastname[i] lines.

Current Input File:
16454025.00
89324020.00
71044012.50
28164026.00
53874021.00
67804013.50
56414011.25

90006025.00
90015020.00
90025523.00

Ideal input file (would include names) Example.
1645 Bob Smith 40 25.00

Syntax:

#include <iostream>
#include <iomanip>
#include<fstream>
using namespace std;
//function prototypes
int readalldata(long int[], int[], float[], const int);
void findovertimehours(int[], int[], int);

[Code] .....

View 8 Replies View Related

C++ :: Program To Pick A Random Name From A File With List Of Names

Oct 28, 2013

I just recently started looking into C++ programming so I don't know much.

I was wondering is it possible to write a program to pick a random name from a list of names, which are in a .txt file? or if I could ask the user to input the list of names and then let the program pick a random name?

View 6 Replies View Related

C++ :: Write A Program That Will Read Names From Input File

Apr 24, 2014

I have a lab with the following instructions:

Manually create an input text file called Lab22BInput.txt with the following data:

Dove
Doe
Alston
Zebra
Egg

Write a program that will read the names from the input file. Print out each of the names read to the screen. The program should go through the list of names and determine which comes 1st in the alphabet. The program should determine how many letters are in this name. Print out the name that comes first in the alphabet and the length of the name.

I have created the input file, and the data correctly outputs to the screen when I run the program. However, I do not know what kind of logic to use to sort them alphabetically and determine the amounts of characters.

So far I have the following:

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string str1, str2, str3, str4, str5;

[Code]...

View 2 Replies View Related

C :: Program To Show Large Text File In Parts

Jan 1, 2014

I am currently working out on a problem in which a c program is to be made which shows a large text file in parts.
f
For example: If file contains 200 lines. 50 lines will be shown on first page and user is asked to press any key to move to next page until EOF is found. user is allowed to return to previous page as well, and this is very complicated task for me. I tried to move cursor to a specific position using fseek etc but it page doesn't stop and reaches to end quickly.

View 1 Replies View Related

C++ :: Program Only Accept Integer From 0-10 But Doesn't Show The Factorial

Feb 28, 2013

#include<iostream>
using namespace std;
int main() {
int a[9],x,f=1;
cout<<"Please enter an integer [0-10 only] : ";

[Code] ....

View 3 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++ :: Best Way To Show A Program Remotely And Also Provide Console Input?

Sep 27, 2013

I want some people to see my C++ program, enter inputs (they can enter number 1, 2, 3, etc) as CIN, and then the program runs as it would if they were sitting in my place.

I have seen a few places which try to do this e.g.

[URL]

The problem is the CIN is not fully featured. For example in the first website you have to enter the input before you run the program. So that would not work for a program where CIN was being done all the time.

So I can get a domain, ask them to telnet into the Linux shell and compile and run my c++ Demo program. Is that the best way? Thats the worst case. I send them the .cpp file and they'll have to run and compile it on their own machine.

The best case is that they click on a link, get an online console and interact with it like they would with a real input/output c++ interface.how this can be done?

View 1 Replies View Related

C++ :: Voter Program - Input Names And Votes / Output Who Won The Vote

Apr 27, 2013

In my class we were supposed to write a program from the book that inputted the names and votes and the program is supposed to spit out who won the vote. I did this then while i was reading the assignment from the instructor I noticed he wanted the information inputted from a TXT file instead of manually inputting it. I cannot seem to get it to work....

#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
#define N 5
char names[N][20];
float votes[N];

[Code] ....

here is the txt file

Johnson 5000
Miller 4000
Duffy 6000
Robinson 2500
Ashtony 1800

View 2 Replies View Related

C :: Transaction Program - Show Balance Of Clients After Withdrawals / Deposit

Jun 13, 2014

I am running a little business on the side, any program I could use that will show me the balances of clients after withdrawals, deposits. For example, if i had a data file like this :

Code:
e 5 Elden
c 3 Felipe 55342.51415
e 3 Leonardo
e 1 Yong

[Code] ....

Lines beginning with 'e' will have an integer employee ID and an employee name.
Lines beginning with 'c' will have an integer customer ID, customer name, and a floating point account balance.
Lines beginning with a 't' will have a customer ID, employee ID, a 'w' or 'd' representing withdrawal or deposit,
and a floating point transaction amount.

Now, obviously the program doesn't have to be exactly like this but something along these lines.

View 4 Replies View Related







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