C++/C++

Advertisement


Question
I have to write a program that reads 3 test scores from the user and return a grade for the course, the maximum score, and all exams.  I wrote the program that follows but i can not get it to work can you please take a look at it?  Thanks


#include <iostream>
#include <iomain>  // For setprecision ()
#include <fstream> // For file I/O
#include <string>  // For string type

using namespace std;

int main ()

{

char  grade;  // Coded ‘A' = 90-100, ‘B' = 80-89, ‘C' = 70-79, ‘D' = 60-69, ‘F' = 0-59
float  average;  //  Maximum test score
float max score  //  Maximum score
float valid  // Valid score
int exam1;   // Grade for the first exam
int exam2;   // Grade for the second exam
int exam3;   // Grade for the third exam


cout << fixed < showpoint  // Set up floating – pt
    << setprecision (2);  // output format

// Get data

cout << “Please enter a test score:  " << end1;  // Prompt
cin >> exam1;

cout << “ Please enter a test score:  " << end1;  //Prompt
cin >> exam2;
       
cout << “Please enter a test score:  " << end1;  // Prompt
cin >> exam3;

cout << "To terminate this program:" << end1;


cout << "Press Q or q, then press Enter..." << end1;
cin => Q | q;
       
cout << “Test Scores:  ” << exam1 << “,” << exam2 << “,” << exam3 << end1;

// Test data
{
if (grade => 90)
cout << "A" << end1;

if (grade => 80)
cout << "B" << end1;

if (grade => 70)
cout << "C" << end1;

if (grade => 60)
cout << "D" << end1;

if (grade => 59)
cout << "F" << end1;
}


  //Calculate average

  average = float (exam1 + exam2 + exam3) / 3.0;

  // Print message

  cout << "Avg"
     << setprecision (2) << average


cout << "Ex1" << exam1 << end1;
cout << "Ex2" << exam2 << end1;
cout << "Ex3" << exam3 << end1;

return 0
}  

Answer
Michelle, Thank you for your question.

"I cannot get it to work" tells me nothing about the problems you have found.

Unfortunately, you have not given me enough information for me to be able to answer your question. Please resubmit your question with more details or a clearer description and I will do my best to answer.

David Spector

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


David Spector

Expertise

Highly knowledgeable in the C++ language, Visual C++ (MSVC), Windows API, documentation and other quality-assurance techniques, and debugging. Knowledgeable in MFC, COM, GUI design, and object-oriented design.

Experience

I have been a software engineer since 1965. I have been published. My specializations have been: biomedical programming, compiler implementation, and many kinds of Windows programming. I don't do Databases or other business-oriented stuff.

Publications
Windows?/DOS Developer's Journal, ACM SIGPLAN Notices, and Computer Science Press.

Education/Credentials
ICCP Systems Programming Certification
Master's degree equivalent in Computer Science

©2016 About.com. All rights reserved.