Can someone fix my code i just get a empty black screen when I run

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Can someone fix my code i just get a empty black screen when I run

A system is set up to take raw grading information from the console and calculate a consolidated
grade. The information comes in as a single line with first name, last name, homework grade ( a tota
out of 20 ), lab grade (a total out of 50 ), exam grade average, and a letter ( upper or lower )
indicating Audit, Passfail, or Grade.
Sample :
Mary Poppins 17 28 87 g
A program should be written that takes the input data and calculates a consolidated FINAL grade
based upon 10% Homework, 20 % Lab , and 70% Exams.
The output should be formatted in columns of 7, no decimals. first initial lastname - normalized
homework-normalized lab-exam-final grade For a pass/fail student output should indicate only
Pass or Fail . For an audit output should say not gradeable
Transcribed Image Text:A system is set up to take raw grading information from the console and calculate a consolidated grade. The information comes in as a single line with first name, last name, homework grade ( a tota out of 20 ), lab grade (a total out of 50 ), exam grade average, and a letter ( upper or lower ) indicating Audit, Passfail, or Grade. Sample : Mary Poppins 17 28 87 g A program should be written that takes the input data and calculates a consolidated FINAL grade based upon 10% Homework, 20 % Lab , and 70% Exams. The output should be formatted in columns of 7, no decimals. first initial lastname - normalized homework-normalized lab-exam-final grade For a pass/fail student output should indicate only Pass or Fail . For an audit output should say not gradeable
Winclude <iostrean>
using nanespace std;
int main() {
cout « "enter first name : ";
cout « "enter last name :";
// Declaring respective variables
string firstNane, lastName;
double homeworkGrade, labGrade, examAvg;
char letter;
// Reading input from console
cin >> firstNane >> lastName;
cin >> homeworkGrade >> 1labGrade >> exanAvg;
cin >> letter;
// Now calculating grade
double homeworkAvg = (homeworkGrade/20.0) * 10.0;
double labavg = (labGrade/50.0) * 20.8;
double examMark = (examAvg/180.0) * 78.8;
double totalAvg = homeworkAvg + labAvg + exanMark;
char grade;
string res = "Pass";
if (totalAvg > 85)
grade = 'A';
else if (totalAvg >= 79 && totalAvg <= 85)
grade - "B';
else if (totalAvg >= 70 &8 totalAvg <= 78)
grade = 'C';
else if (totalAvg >= 60 &8 totalAvg <= 69)
grade = 'D';
else if (totalAvg >= 50 &8 totalAvg <= 59)
grade = 'E';
else {
grade - "F';
res = "Fail"; // neans candidate is fail
// Now showing formatted outputs
cout « "Output:-" « endl;
cout « firstName <« " " <« lastName <« " "
« (int)homeworkAvg <<
* « (int)labAvg « " " « (int)exanMark «" ";
// Now showing grade or pass/fail based on letter
if (letter == 'A' || letter == 'a')
cout « "not gradable";
else if (letter == "P' || letter == "p')
cout « res;
else if (letter == "G' || letter == 'g')
cout « grade;
cout <« endl;
return e;
Transcribed Image Text:Winclude <iostrean> using nanespace std; int main() { cout « "enter first name : "; cout « "enter last name :"; // Declaring respective variables string firstNane, lastName; double homeworkGrade, labGrade, examAvg; char letter; // Reading input from console cin >> firstNane >> lastName; cin >> homeworkGrade >> 1labGrade >> exanAvg; cin >> letter; // Now calculating grade double homeworkAvg = (homeworkGrade/20.0) * 10.0; double labavg = (labGrade/50.0) * 20.8; double examMark = (examAvg/180.0) * 78.8; double totalAvg = homeworkAvg + labAvg + exanMark; char grade; string res = "Pass"; if (totalAvg > 85) grade = 'A'; else if (totalAvg >= 79 && totalAvg <= 85) grade - "B'; else if (totalAvg >= 70 &8 totalAvg <= 78) grade = 'C'; else if (totalAvg >= 60 &8 totalAvg <= 69) grade = 'D'; else if (totalAvg >= 50 &8 totalAvg <= 59) grade = 'E'; else { grade - "F'; res = "Fail"; // neans candidate is fail // Now showing formatted outputs cout « "Output:-" « endl; cout « firstName <« " " <« lastName <« " " « (int)homeworkAvg << * « (int)labAvg « " " « (int)exanMark «" "; // Now showing grade or pass/fail based on letter if (letter == 'A' || letter == 'a') cout « "not gradable"; else if (letter == "P' || letter == "p') cout « res; else if (letter == "G' || letter == 'g') cout « grade; cout <« endl; return e;
Expert Solution
Step 1

Code:

 

#include <iostream>
using namespace std;

int main() {
  
   // Declaring respective variables

   string firstName, lastName;
   double homeworkGrade, labGrade, examAvg;
   char letter;
   cout<<"enter first name and last name and homework grade , labgrade , exam grade average and a letter : "<<endl;
   // Reading input from console
  
   cin >> firstName >> lastName;
   cin >> homeworkGrade >> labGrade >> examAvg;
   cin >> letter;
  
   // Now calculating grade
  
   double homeworkAvg = (homeworkGrade / 20.0) * 10.0;
   double labAvg = (labGrade / 50.0) * 20.0;
   double examMark = (examAvg / 100.0) * 70.0;
  
   double totalAvg = homeworkAvg + labAvg + examMark;
  
   char grade;
   string res = "Pass";
  
   if(totalAvg > 85)
       grade = 'A';
   else if(totalAvg >= 79 && totalAvg <= 85)
       grade = 'B';
   else if(totalAvg >= 70 && totalAvg <= 78)
       grade = 'C';
   else if(totalAvg >= 60 && totalAvg <= 69)
       grade = 'D';
   else if(totalAvg >= 50 && totalAvg <= 59)
       grade = 'E';
   else {
       grade = 'F';
       res = "Fail"; // means candidate is fail
   }
  
   // Now showing formatted outputs
  
   cout << "Output:-" << endl;
   cout << firstName << " " << lastName << " "
       << (int)homeworkAvg << " " << (int)labAvg << " " << (int)examMark << " ";

   // Now showing grade or pass/fail based on letter
      
   if(letter == 'A' || letter == 'a')
       cout << "not gradable";
   else if(letter == 'P' || letter == 'p')
       cout << res;
   else if(letter == 'G' || letter == 'g')
       cout << grade;

   cout << endl;

   return 0;
}

 

 

 

Computer Science homework question answer, step 1, image 1

 

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education