C :: Convert A Number Grade To A Letter Grade
Feb 24, 2013
i'm having trouble with my c programming assignment. i'm trying to convert a number grade to a letter grade. I'm trying to Write a function (called: numToLetter) that takes as input a number from 0 to 100 and returns a character ( a single character ), based on the following: if the number is between 60 and 70 return Dif the number is greater than 90 return Aif the number is between 70 and 80 return Cif the number is between 0 and 60 return Fif the number is between 80 and 90, return B and i need to use the return statements to call the function like for example:
if (a > 90) return ('A');
elseif (a > 80)
return ('B');
elseif (a > 70)
return ('C'); else
return ('F');
how do if write my code with this function?
View 1 Replies
ADVERTISEMENT
Apr 23, 2014
I have to accept the numerical grade and determine the letter grade that the user will receive. I have to use a grading table to determine the letter grade based on the numerical grade. The Letter Grade table is
A 90-100
B 80-89
C 70-79
D 60-69
F 59 and below
Here is the code
//preprocessor directives
#include <iostream>
#include <string>
//namespace statement
using namespace std;
//function prototypes
void getData (string& course, string& first, string& last, int& grade);
[Code] ......
As you can see, I am currently stuck on the determineGrade one
View 1 Replies
View Related
Feb 7, 2013
So I have to write a program to calculate a grade letter into a number.
Letter grades are A, B, C, D, and F, possibly followed by + or –. Their numeric values are 4, 3, 2, 1, and 0. There is no F+ or F–. A + increases the numeric value by 0.3, a – decreases it by 0.3. If the letter grade is illegal (such as "Z"), then your output should be "INVALID LETTER GRADE"; If the combination is illegal (such as "A+" or "F-") then your output should be "INVALID GRADE COMBINATION"
Also the code should look like this
Enter your letter grade: C+
Grade value is [2.3]
// Input
cout << "Enter your letter grade: ";
string s;
cin >> s;
[Code].....
View 2 Replies
View Related
Apr 7, 2013
I'm writing a program to calculate a final grade by adding 4 numbers minus the lowest grade and dividing by 3. My knowledge in c is not extensive I thought that a simple assigment operator would do the job but I'm getting a strange large numbers in the execution.
Code:
#include <stdio.h>
#include <stdlib.h>
main(){
int eg, g1, g2, g3, g4, fg, s1, s2, sg;
[Code] ....
View 4 Replies
View Related
Jun 26, 2013
I get so close, and then it seems my brain shuts down ... I need to write a program that outputs a histogram of student grades for an assignment. The program should input each student's grade as an integer and store the grade in a vector. Grades should be entered until the user enters -1 for a grade. The program should then scan through the vector and compute the histogram. In computing the histogram, the minimum value for a grade is 0, but your program should determine the maximum value entered by the user. Use a dynamic array to store the histogram. Output the histogram to the console. For example, if the input is:
20
30
4
20
30
30
-1
Then the output should be:
Number of 4’s: 1
Number of 20’s: 2
Number of 30’s: 3
I can't quite get my output to look like that:
/* This program will display the histogram of student grades for an assignment */
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <conio.h>
[code]......
View 3 Replies
View Related
Feb 9, 2015
The code runs but asks me for my score twice then just comes to an abrupt end with out giving me a letter grade.
#include <stdio.h>
int getScore(void);
char convertGrade(int numscore, char letterGrade);
void showGrade(int numscore, char letterGrade);
// Function to prompt for and read a numeric score
// Returns an integer score as read in using scanf
[Code] ....
View 12 Replies
View Related
Jul 5, 2014
Write a program which is used to calculate the GPA based on the grades for different courses input by user. User should be able to use this to enter grades for as many courses as he wants unless he wants to quit. (you may consider using some loop). Once user has completed entering of data, the program should be able to provide a feedback to the user about the GPA. A is equal to 4, B is equal to 3, C is equal to 2, D is equal to 1, rest are 0. Use minimum 5 course to demonstrate working of your code.
Here is an example (User input is in italic and bold):
Would you like to enter grades: Y
Please enter the course name: COSC1301
Please enter your grade: A
Would you like to enter more grades: Y
Please enter the course name:ITSE1301
Please enter your grade: B
Would you like to enter more grades: Y
Please enter the course name:ITSE2409
[code]....
View 4 Replies
View Related
Apr 15, 2014
I have a text file containing the names and surnames of enrollment numbers and grades of students , looks like this:
RIKI Rikic E2345678 10
JUPI jupic E1232345 9
Etc ......)
I'm interested in sorting by name and surname, registration number and grade.My example:
struct student {
string name;
string surname;
string enrollment;
int grade;
};
and in the main program
int main () {
Student STUDENT;
/ / Code to read a text file that I wrote so I have ...
switch ()
case '1 ': / / sort by name
case 2: / / by surname
Case 3 / / by enrollment
Case 4 / / by grade
this sort we are not going very well .
View 1 Replies
View Related
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
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
Sep 3, 2013
My average is failing but I played and played with it and I still keep crashing.
Code: #include <iostream>
using namespace std;
void getScore(int score[], int NumGrades)
{
cout<<"How many grades do you need to enter?"<<endl;
cin >> NumGrades;
cout<<"Enter the Students Grade(s)"<<endl;
for (int i=0; i<NumGrades; i++) {
cin >> score[i];
[code].....
View 9 Replies
View Related
Nov 15, 2014
i cant seem to get the program to return the right grade it keeps returning 0 or 1. i want the program to return true for grades grades greater then or equal to 70 but cant find the right formula to put in the bool(). what formula should i put?
#include <iostream>
#include <cstdlib>
#include <time.h>
[Code]....
View 3 Replies
View Related
Aug 3, 2014
How to find a lowest grade in programing using the c++.
example: {65,89,100,76,80}.
#include<iostream>
using std::cout;
using std::endl;
int main() {
float grade=0;
[Code] .....
View 1 Replies
View Related
Apr 8, 2015
I am attempting to reconfigure a working code that before used while loops and if statements to convert a numeric score to a letter grade. I now wish to take this same code however I want to change the char convertGrade(int numScore) to simply use a parallel array as a replacement to the if statements.
The array needs to consist of 3 arrays of fixed size 5:
int minScores[SIZE]
int maxScores[SIZE]
char letterGrade[SIZE]
I know the declarations need to go in the function convertGrade but this is the first time I have worked with arrays and I am having trouble trying to figure out how this array will replace my previous if statement.
In order to access the array elements I need to write specifications such as
minScores[i]
maxScores[i]
letterGrade[i]
(where i = 0, 1, 2, 3, or 4)
#include <stdio.h>
#include <stdlib.h>
#define SIZE 5
int getScore(void);
char convertGrade(int numScore);
[Code] .....
View 5 Replies
View Related
Jan 2, 2014
I am trying to get this program to accept two inputs Student number and grade and validate them both
However the program skips over the student number
Code attached AssignmentProgram.c
View 1 Replies
View Related
Nov 25, 2013
I am trying to correlate the student's highest score with that student's ID. The old code is in blue and the new code is in green which includes a sort. The particular information in question is in red.
Ide1
Code:
#include <stdio.h>
int main(void) {
/*Set up two arrays to include up to 50 elements each.*/
int st_numval_id[50] = {0}, st_val_tstscr[50]= {0}, i = 0, j = 0, temp;
[Code] .....
Enter the student's id and test score:
/*After the following input, then enter 0 to end the input*/
Student ID Test Score Letter Grade
------------ ----------- --------------
1653 77 C
1945 72 C
1020 50 F
1955 92 A
1900 81 B
ABOVE AVERAGE STUDENTS
Ave Test Score Students Above Ave Number of: A's B's C's D's F's
----------- ---------- --------- --- --- --- --- ---
62.00 4 1 1 2 0 1
THE STUDENT WITH THE HIGHEST TEST SCORE
Student ID Test Score Letter Grade
--------- ---------- ------------
1900 0 F
Press any key to continue...
View 1 Replies
View Related
Jul 2, 2014
I wrote a program to grade T or F test. It is running, but not outputting the information.
Code:
#include<iostream>
#include<string>
#include<fstream>
#include<iomanip>
using namespace std;
double grading(char*answer, char* stuResponse, double graded);
[Code] ...
text doc:
TFFTFFTTTTFFTFTFTFTT
ABC5403 TFTFTFTT TFTFTFFTTFT
ABC5404 TFTFFTTFFTFFFTTTFTFT
View 5 Replies
View Related
Sep 14, 2014
I had to write a simple program that prompted the user for various test scores and it would pump out his grade average at the end. I did that with no issue, however, my instructor wants me to add something to the end off the code and I'm not sure how to do that. My code is:
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
string tempType;
float SumTest, MaxTest, TestAve,ProgAve,output;
[Code] ....
And this is what I'm supposed to add, the averages are supposed to have numbers from what the user gave.
***************************
Grade Calculator
Program Average
Test Average
Final Grade
***************************
View 6 Replies
View Related
Oct 29, 2014
I need to get Students to input there Name And Score > and for me to output the grade. This works but I want to tidy this up so I can see all the names and grades when the program finishes.
#include "stdafx.h"
#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
[Code] ....
View 9 Replies
View Related
Feb 24, 2013
I am a math teacher who is taking a programming class. My district wants to incorporate some programming tasks into the high school math curricula. I am working on a project to calculate a final grade and output this along with a comment to a text file. The following data is the input that I created:
3 300 100 100 100 .15
4 400 100 98 94 92 .45
3 300 98 100 92 .40
The final grade output results in gibberish.
#include <iostream>
#include <fstream> // For file I/O
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;
[Code] ....
View 6 Replies
View Related
Nov 21, 2014
Remove the break statements from each of the cases. What is the effect on the execution of the program?
Add an additional switch statement that allows for a Passing option for a grade of D or better. Use the sample run given below to model your output.
Sample Run: What grade did you earn in Programming I ? A YOU PASSED! an A - excellent work!
Rewrite the program LastFirst_lab44.cpp using if and else if statements rather than a switch statement. Did you use a trailing else in your new version? If so, what did it correspond to in the original program with the switch statement?
// This program illustrates the use of the Switch statement.
// The break statement causes all subsequent expressions to be executed as well, also known as "falling through".
// The trailing else statement acts just like the default section if none of the options from before work it gets "defaulted" to it.
#include <iostream>
using namespace std;
int main() {
char grade;
cout << "What grade did you earn in Programming I ?" << endl;
[code]....
how do you add an additional switch statement? i tried multiple times and i'm not sure if i don't understand braces enough but it didnt seem doable. also, I'm not sure what the teacher wants me to submit.
View 1 Replies
View Related
Apr 18, 2013
Trying to write a program that calculates a students grade based on how many assignments have been graded. I am using a switch case since there is a total of 5 assignments, however when I enter case 1, and enter in how many I got out of 100, it just closes the program it doesn't go to the next part.
#include <iostream>
using namespace std;
char calculategrade(int total);
int main() {
// local variable declaration:
char input;
[Code]....
View 6 Replies
View Related
Mar 5, 2013
Write a program that calculates the total grade for N classroom exercises as a percentage. The user to input the value for N followed by each of the N scores and totals. Calculate the overall percentage (sum of the total points earned divided by the total point possible) and output it as a percentage. Sample input and output it as a percentage. Sample input and output is shown below.
How many exercises to input?
score1: 10
total points possible: 10
score2: 7
total points possible: 12
score3: 5
total points possible: 8
Code:
# include <iostream>
using namespace std;
int main () {
double N=0, score, total, totalScore=0, totalGrade=0, GRADE;
cout<<"How many excersices will be scored?/n";
[Code] .....
Error:
1>------ Build started: Project: HOMEWORK5, Configuration: Debug Win32 ------
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>C:UsersWORKHOMEWORK5DebugHOMEWO… : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
View 4 Replies
View Related
Sep 15, 2014
I am trying to code a program that takes in user inputted data about percentages and using it to later on calculate a final grade. 4 percents are inputted, for Assignments, Midterm1, Midterm2, and Finals. If the percents dont add up to 1 (i tell the user to enter the decimal value) I set up and if statement to catch it and end the program. Except that if i type in
Assignments = .3
Midterm1 = .3
Midterm2 = .3
Finals = .1
the program doesn't recognize that they add up to 1. Heres the relevant portion of my code [URL] ....
Here's some examples of how it works [URL] ....
And heres what i dont understand [URL] ....
Why is it saying .3 + .3 + .3 + .1 != 1 when .1 + .3 + .3 + .3 == 1?
View 1 Replies
View Related
Dec 10, 2014
Write a program that inputs a string and then converts each 1st letter of a word in the string into capital case. An example run of the program is shown below:
Enter string: introduction to programming
Output string: Introduction To Programming
View 1 Replies
View Related
Feb 25, 2014
In C how can I initialize a variable that is not a letter or number? For example with a number I can :
Code:
int i = 5;
for ( i = 0; i <=5; i++ );
printf( "%d", i ) This would display a row of 5's
but what if I wanted to display a row of -----? What I am trying to do is read in a simple txt file, around the file I want ----1----2-----3 ect ect on the top ----a----b-----c down the side Then I want to be able to change the file at lets say position c2 and save it. This is the early stages of my attempt to set up a editable table.
View 3 Replies
View Related