C++
1: Grade
Prompt the user for name (first name only, only one word) and score (which will be input as a fixed
point number). Input the values, c&d on input failure. The score should be in the range [0, 100],
otherwise c&d.
Compute the grade and output with explanatory text.
The grade for most students according to
[85, 100]:
A
[73, 85):
B
[61, 73):
C
[49, 61):
D
[0, 49):
F
(Note that in the above I use [] to indicate that the boundary is included in the range, and () to
indicate that the boundary is not included.)
However: If the student's first name matches my first name ("Bob") or your first name, and if the
student earns less than A, then the student's grade is changed to improve it by one letter grade.
An example run of your program might go as
name score:
Ebeneezer 73
Ebeneezer gets B
Another example run of your program might go as
name score:
Bob 73
Bob gets A
(Recall that strings can be compared with the == and != operators, so it's pretty simple to test
whether the name is one of the two special names.)
#include<iostream>
#include <string>
#include<bits/stdc++.h>
using namespace std;
int main (){
string name, temp, name1 = "bob", name2 = "danny";
float grade;
cout<<"name score: \n";
cin>>name;
std::fflush;
cin>>grade;
if(cin.fail())
{
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(),'\n');
cout<<" input failure.. input grade in range [0,100] : "<<endl;
cin>>grade;
}
temp=name;
transform(temp.begin(), temp.end(), temp.begin(), ::tolower);
if( grade >= 85 && grade <= 100 )
cout << name << " gets A";
else if( grade >= 73 && grade < 85 ) {
if( temp == name1 || temp == name2 )
cout << name << " gets A";
else
cout << name << " gets B";
}
else if( grade >= 61 && grade < 73 ) {
if( temp == name1 || temp == name2 )
cout << name << " gets B";
else
cout << name << " gets C";
}
else if( grade >= 49 && grade < 61 ){
if( temp == name1 || temp == name2 )
cout << name << " gets C";
else
cout<<name<<" gets D";
}
else if( grade >= 0 && grade < 49 ){
if( temp == name1 || temp == name2 )
cout << name << " gets D";
else
cout<<name<<" gets F";
}
return 0;
}
C++ 1: Grade Prompt the user for name (first name only, only one word) and score...
C++ CS : if die's job is to output an error message alarmingly and terminate the program. You may copy my function definition, or use your own: // The following 4 lines should be present if we have a die function: #include <iostream> // cout, endl #include <string> // string #include <cstdlib> // exit, EXIT_FAILURE using namespace std; bool die(const string & msg){ cout <<"Fatal error: " <<msg <<endl; exit(EXIT_FAILURE); } 1. Tier Prompt the user, then input the student's...
For C++ program Your program should first prompt the user for the number of students they wish to enter. For each student, the user will be prompted to enter the student’s name, how many tests the student has taken, and the grade for each test. Each test’s grade will be inputted as a number representing the grade for that test. Once each student’s information has been entered, the program will display the number of students. Additionally, each student will have...
Write a C++ program that computes student grades for an assignment as a percentage given each student's score and the total points. The final score must be rounded up to the nearest whole value using the ceil function in the <cmath header file and displayed as a percentage. You must also display the floating-point result up to 5 decimal places. You must use at least 2 functions: one to print the last name of the student and another function to...
Java programming only Create a Java program that inputs a grade from the user. The grade input from the user will be an integer. Once the input is stored, use an if-else-if block of code to determine the letter grade of the inputted integer grade. Do not use a bunch of if statements by themselves to solve this problem. You will print an error message for inputs greater than 100 and for inputs less than 0. Both errors must be...
C++ Loops homework Prompt the user for a desired password, input the password. Your program may assume without checking that there is no input failure and that the password contains no white space. Let's say the rules for a legal password are: # chars must be in [4, 8] # digs must be >= 2 The password must contain at least one letter of each case The password must contain at least one char that's not a letter or digit...
Topics c++ Do While loops cin.ignore Description Redo the last assignment with the following modifications: 1. When the program asks the user to enter a student name, the user will enter the full name (e.g. John Smith). Make changes to the program to accommodate that. 2. When the program asks the user to enter the test score, the user will enter the test score as before. However, make changes to the program so that it will check that the score...
In Java Main method Your main program will prompt the user for a test name and the number of scores the user will enter. After creating an arraylist to hold the scores, prompt the user for all the scores to hold in the arraylist. After all the scores are entered, then repeat back the score & letter grade. GradeBook Object Create an instance of a GradeBook object and pass the test name and arraylist to set the instance variables. At...
This is in C++.
Example:
You will write a program that will prompt the user to enter a grade out of 100 and then show them what the equivalent grade points value is. The main() function will handle the input and output tasks, but the actual conversion will occur in a function called GradePoints(). GradePoints Specifications This function is strictly a processing function, meaning that there are no console input or output steps in the actual function. Consider that this...
I asked a question similar to this one, which was answered perfectly. Another practice problem is now asking me to use two classes and get user input. For this Java program, you will write two classes: GradeCalculator and GradeCalculatorDriver In the GradeCalculator class, compute the final average and letter grade for a particular student. The final average is calculated according to the following rules: 1) There are ten exams scored out of 100 points 2) The lowest exam score is...
12.8 GPA reports using files Prompt the user by "Enter name of input file: " for the name of an input file and open that file for reading. The two input files for the tests are already at the zyBooks site.They each have a list of student names with the course they have taken, of the form Jacobs, Anthony ECS10 4 B- ECS20 4 C+ ANS17 3 A ANS49H 2 D Wilson, Elaine ECS10 4 B+ ECS20 4 C+ ANS17...