C++ :: Program To Calculate A Grade Letter Into Number?
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;
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');
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
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.
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";
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):
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>
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
I have an assignment to write a program that will calculate the number of days between two dates (including leap years). We have to read the data from a file and in my current input file I have:
for testing purposes. When I run the program the console runs continuously spouting out "The days between your two dates are 1097." Which would be the correct output for the last set of dates entered, but I need to find out where I've messed up in my main.
#include <iostream> #include <fstream> using namespace std; bool isLeap(int x) { if (x % 400 == 0) {
I am trying to code and compile a program that requests a uses to first inpu the number of sides they wish for a dice to have and secondly input the number of dice throws they would like to calculate the value for. The program will print an error message and default the number of sides the dice has to 5 if the number entered is below 4. Finally it will print out a percentage figure for each value that results from all the the dice rolls.
I have attached my header, driver and class files below along with accompanying error messages below them
// file name Exercise.cpp #include <iostream> #include "Die.h" using namespace std; int main() // the main program begins here { char restart = 'y'; // declare variables double numRolls = 0.0; int diceTot = 0;
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?
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.
For example if I have typed 0xFF (a literal hex number that represents the value 255 for Unsigned Char or -1 for Signed Char) in part of my program. That 0xFF is treated as a Char not an Int, because the value is within the range supported by Char, the C compiler always tries to use the smallest datatype possible for the number that is needed for a literal value like this.
Unfortunately because Signed Char is the default Char type, 0xFF is translated into -1. I am wanting to use it to represent 255. So I'm trying to tell the compiler that 0xFF should be interpreted as either an Int or an Unsigned Char. How do I do this?
I already tried typing it with the magic letter "I", like this: 0xFFI
But that didn't work. What is the correct way to do this?
I am working on Euler Project exercise number 17. Here is the problem from the website.
"If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?"
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;
Dont know how to replace each letter as s number ... this is the question i was given ...
In cryptarithmetic puzzles, mathematical equations are written using letters. Each letter can be a digit from 0 to 9, but no two letters can be the same. Here is a sample problem:
SEND + MORE = MONEY
A solution to the puzzle is S = 9, R = 8, O = 0, M = 1, Y = 2, E = 5, N = 6, D = 7.
Write a program that finds a solution to the cryptarithmetic puzzle of the following:
TOO + TOO + TOO + TOO = GOOD
The simplest technique is to use a nested loop for each unique letter (in this case T, O, G, D). The loops would systematically assign the digits from 0 to 9 to each letter. For example, it might first try T=0,O=0,G=0,D=0, thenT=0,O=0, G = 0, D = 1, then T = 0, O = 0, G = 0, D = 2, etc., up to T = 9, O = 9, G = 9, D = 9. In the loop body, test that each variable is unique and that the equation is satisfied. Output the values for the letters that satisfy the equation.
I am trying to fill an array with blank spaces and instead i get the number 32 over and over, i think this is the ANSI code for that character. how do i get the character itself?
I have a string - a whole sentence that I want to assign a number to each letter, space, comma and period etc. So all "A's" will have the same number, all "B's" will have another number etc. I don't want to use the ASCII numbers because they all need to be sequential and some of the punctuation isn't. I have put the string into a char array to separate each character out and was thinking about running it through a loop with if statements for each letter and assigning numbers there and then saving the numbers in the order they appear into a list as a string but I keep coming up with errors so I don't know how to do it or if there is a better way to accomplish what I'm trying to do.