Why is this not giving me a letter grade when run?
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double grade1, grade2, grade3, grade4, total;
cout << "please enter the first grade : ";
cin >> grade1;
cout << "Please enter the second grade : ";
cin >> grade2;
cout << "Please enter the third grade : ";
cin >> grade3;
cout << "Please enter the fourth grade : ";
cin >> grade4;
total = (grade1 + grade2 + grade3 + grade4) / 4;
cout << "The average grade is : " << setprecision(6) << total << endl;
const int A_score = 90,
B_score = 80,
C_score = 70,
D_score = 60;
int testScore;
cin >> testScore;
if (testScore >= A_score)
cout << "Your grade is A.\n";
else if (testScore >= B_score)
cout << "Your grade is B.\n";
else if (testScore >= C_score)
cout << "Your grade is C.\n";
else if (testScore >= D_score)
cout << "Your grade is D.\n";
else if (testScore >= 0)
cout << "Your grade is F. \n";
else
cout << "invalid test score.\n";
return 0;
}
Your code is correct. There is no error in the code.
I have run in my PC and it worked fine.
There must have been some mistakes in your method of executing the program. So, please try to execute in proper way and if you still face any difficulty let me know in which way are you executing it like in which ide you are facing the problem.
Sample Output:
Screenshot of the code :

If the answer helped please upvote, it means a lot and for any query please comment.
Why is this not giving me a letter grade when run? #include <iostream> #include <iomanip> using...
How would i be able to use If/else statements on this code for it to give me a letter grade at the end? #include <iostream> #include <iomanip> using namespace std; int main() { double grade1, grade2, grade3, grade4, total; cout << "please enter the first grade : "; cin >> grade1; cout << "Please enter the second grade : "; cin >> grade2; cout << "Please enter the third grade : "; cin >> grade3; cout << "Please enter the...
im not sure why my code isnt working? include <iostream> #include <iomanip> using namespace std; int main() { int amountOfCoffee; double Price; char salesTaxChargeability; double TotalAmount; const double SALESTAX = 0.035; // 3.5 % cout << "\nEnter the number of pounds of coffee ordered in Pounds :"; cin >> amountOfCoffee; cout << "\nEnter the price of coffee per Pound :"; cin >> Price; cout << "\nIs sales tax Chargeable (y or n): "; cin >> salesTaxChargeability; if ( (salesTaxChargeability ==...
my program wont run on my computer and im not understanding why. please help. #include<iostream> #include<iomanip> #include<string> #include "bookdata.h" #include "bookinfo.h" #include "invmenu.h" #include "reports.h" #include "cashier.h" using namespace std; const int ARRAYNUM = 20; BookData bookdata[ARRAYNUM]; int main () { bool userChoice = false; while(userChoice == false) { int userInput = 0; bool trueFalse = false; cout << "\n" << setw(45) << "Serendipity Booksellers\n" << setw(39) << "Main Menu\n\n" << "1.Cashier Module\n" << "2.Inventory Database Module\n" << "3.Report Module\n"...
Use this code to create multiple functions.
#include<iostream>
#include<iomanip>
#include<fstream>
using namespace std;
int main()
{
cout << fixed << showpoint <<
setprecision(2);
ofstream outFile;
outFile.open("Feras's.txt");
outFile << "..Skinny Feras's Restaurant ..\n\n" <<
endl;
int choise=10, quantity;
float paid, SubTotal=0, Tax = .10, Total, RM, more;
while(choise!=0)
{
system("cls");
cout << "\t**Welcome To Skinny Alsaif Restaurant Lol**"
<< endl;
cout << "\nWhat would you like to have?" <<
endl;
cout << "1. Burger." << endl;
cout << "2. Pizza." <<...
#include <iostream> #include <chrono> using namespace std; double improvedPow(double x, int y) { // To be implemented by you } int main() { cout << "To calculate x^y ..." << endl; double x; int y; cout << "Please enter x: "; cin >> x; cout << "Please enter y: "; cin >> y; if(x == 0) { if (y > 0) cout << 0 << endl; else cout << "x^y is not defined" <<endl; } else { cout << improvedPow(x,y)...
#include <iostream> #include <vector> #include <iomanip> using namespace std; int main() { const int NUM_ITEMS = 8; vector <double> inverse(NUM_ITEMS); int j; double temp; for (int i = 0; i < NUM_ITEMS; i++) { inverse.at(i) = 1 / (i + 1.0); } cout << fixed << setprecision(2); cout << "Original vector..." << endl; for (int i = 0; i < NUM_ITEMS; i++) { cout << inverse.at(i) << " "; } cout << endl; cout << "Reversed vector..." << endl; for...
#include "stdafx.h" #include <iostream> using namespace std; class dateType { private: int dmonth; int dday; int dyear; public: void setdate (int month, int day, int year); int getday()const; int getmonth()const; int getyear()const; int printdate()const; bool isleapyear(int year); dateType (int month=0, int day=0, int year=0); }; void dateType::setdate(int month, int day, int year) { int numofdays; if (year<=2008) { dyear=year;...
graph binary search for size and time c++ //System Libraries #include <iostream> #include <string> #include <cstdlib> #include <ctime> #include <iomanip> #include <algorithm> using namespace std; //User Libraries //Global Constants, no Global Variables are allowed //Math/Physics/Conversions/Higher Dimensions - i.e. PI, e, etc... //Function Prototypes //Execution Begins Here! int main(int argc, char** argv) { int n, i, arr[50], search, first, last, middle,count=0,count_in,tot; clock_t start, end; float duration; cout<<"Enter total number of elements :"; cin>>n; cout<<"Enter numbers"; for (i=0; i<n;i++) cin>>arr[i]; cout<<"Enter a...
This is C++ code for parking fee management program #include <iostream> #include <iomanip> using namespace std; void input(char& car, int& ihour,int& imin, int& ohour, int& omin); void time(char car, int ihour, int imin, int ohour, int omin, int& phour, int& pmin, int& round, double& total); void parkingCharge (char car, int round, double& total); void print(char car, int ihour, int imin, int ohour, int omin, int phour, int pmin, int round, double total); int main() { char car; int ihour; int...
I need a detailed pseudocode for this code in C ++. Thank you #include <iostream> #include <string> #include <iomanip> using namespace std; struct Drink { string name; double cost; int noOfDrinks; }; void displayMenu(Drink drinks[], int n); int main() { const int size = 5; Drink drinks[size] = { {"Cola", 0.65, 2}, {"Root Beer", 0.70, 1}, {"Grape Soda", 0.75, 5}, {"Lemon-Lime", 0.85, 20}, {"Water", 0.90, 20} }; cout <<...