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 fourth grade : ";
cin >> grade4;
total = (grade1 + grade2 + grade3 + grade4) / 4;
cout << "The average grade is : " << setprecision(6) << total << endl;
return 0;
}
#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;
char letterGrade;
if (total >= 90)
letterGrade = 'A';
else if (total >= 80)
letterGrade = 'B';
else if (total >= 70)
letterGrade = 'C';
else if (total >= 60)
letterGrade = 'D';
else
letterGrade = 'F';
cout << "Letter grade is " << letterGrade << endl;
return 0;
}
How would i be able to use If/else statements on this code for it to give...
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...
Consider the following program in which the statements are in the incorrect order. Rearrange the statements so that the program prompts the user to input the height and the radius of the base of a cylinder and outputs the volume and surface area of the cylinder. Formant the output to two decimal places. #include <iomanip> #include <cmath> int main () {} double height; cout << ”Volume of the cylinder = “ <<PI * pow(radius, 2.0) * height << endl; cout...
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 ==...
#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)...
How to turn this file into a main.cpp, a header which contains the function declaration, and a implementation fiel containing the function definition ? #include<iostream> #include<string> #include<iomanip> using namespace std; #define NUM 1 #define MULT 4 void getPi(int iter); int main() { int it; cout << "Enter the number of iterations needed to find PI: "; cin >> it; while (it < 1) { cout << "Error!!! Iteration input should be positive." << endl;...
PLEASE TYPE OUT IN TEXT (please no pdf or writing) C++ CODE Consider the following program in which the statements are in the incorrect order. Rearrange the statements in the following order so that the program prompts the user to input: The height of the base of a cylinder The radius of the base of a cylinder The program then outputs (in order): The volume of the cylinder. The surface area of the cylinder Format the output to two decimal...
(C++) I need to alter the code below to fit the given requirements. You will need to move the calculations to a function. A second function to return the Letter Grade. You will need to define a namespace to contain the CONST. Also, need to define an enum for letter grades: A, B, C, D, and F. Console Student Grade Calculation Form First Name: Larry Last Name: Hobbs Homework Average: 65 Midterm Grade: 90 Final Exam Grade: 75 Student: Larry...
Today assignment , find the errors in this code and fixed them. Please I need help with find the errors and how ro fixed them. #include <iostream> #include <cstring> #include <iomanip> using namespace std; const int MAX_CHAR = 100; const int MIN_A = 90; const int MIN_B = 80; const int MIN_C = 70; double getAvg(); char determineGrade(double); void printMsg(char grade); int main() { double score; char grade; char msg[MAX_CHAR]; strcpy(msg, "Excellent!"); strcpy(msg, "Good job!"); strcpy(msg, "You've passed!"); strcpy(msg, "Need...
Please pay special attention to the question asked. Code written
must work when replacing it for "//write your code
here" in the image below. Must be in
C++
I only need the code to replace "//write your code here" with.
You don't need to resend the given code.
The given code in text format for
your convenience:
#include <iostream>
#include <iomanip>
using namespace std;
//rectangle class
class Rectangle {
public:
double areaOfRectangle(double l, double w) {
if (l > 0...
What did I do wrong with this C++ code? Assume that we don't need to ask users for the number of students. #include <iostream> #include <iomanip> using namespace std; int main() { float *grades; // a pointer used to point to an array int size; int count = 0; // track the number of grade/student float grade; // the grade of a student float average, total; // average grade and total grades //**************start your code here************************ cout<<"How many student grades...