Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include #include using namespace std; // Function to determine the grade description based on the percentage string getGradeDescription(double percentage) { if (percentage >=

#include #include #include #include

using namespace std;

// Function to determine the grade description based on the percentage string getGradeDescription(double percentage) { if (percentage >= 90) { return "Excellent"; } else if (percentage >= 80) { return "Well Done"; } else if (percentage >= 70) { return "Good"; } else if (percentage >= 60) { return "Need Improvement"; } else { return "Fail"; } }

int main() { // Replace "input.txt" with the name of your input data file ifstream inputFile("input.txt");

// Check if the file was opened successfully if (!inputFile.is_open()) { cerr << "Error: Could not open the input file." << endl; return 1; }

// Read score and total points from the input file double score, totalPoints; inputFile >> score >> totalPoints;

// Calculate the percentage and round up to the nearest whole value double percentage = (score / totalPoints) * 100; int roundedPercentage = ceil(percentage);

// Display the result with proper formatting cout << "Score: " << score << " out of " << totalPoints << endl; cout << "Percentage: " << fixed << setprecision(5) << percentage << "%" << endl; cout << "Rounded Percentage: " << roundedPercentage << "%" << endl; cout << "Grade: " << getGradeDescription(percentage) << endl;

// Close the input file inputFile.close();

// Closing program statements system("pause"); return 0; }

using this code, create the external data file used that C++ will use to extract the data from for the last name, and score

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions