Question

/* C++ program that prompts the user to enter the name of the student, enter the...

/*
C++ program that prompts the user to enter the name of the student,
enter the five scores values. Then calculate the total scores of the student.
Then finally calculate the average score of the total score value.
Then, print the name, total score , average scrore value on console output.
*/
//main.cpp
//include header files
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
//start of main function
int main()
{
   //declare variable to read string value
   string studentName;
   //declare variables of float variables
   float participationScore;
   float testScore;
   float assignmentScore;
   float examScore;
   float practiceScore;
   //Set float variables to 0
   float totalScore = 422;
   float averageScore = 84.4;
   cout << "Enter the Student's name:Jhon Smith ";
   //read student name
   getline(cin, studentName, '\n');
   //read scores
   cout << "Enter Class Participation Score ranging from 89:";
   cin >> participationScore;
   cout << "Enter Test Score ranging from 87:";
   cin >> testScore;
   cout << "Enter Assignment Score ranging from 67:";
   cin >> assignmentScore;
   cout << "Enter Exam Score ranging from 99:";
   cin >> examScore;
   cout << "Enter Practice Score ranging from 80:";
   cin >> practiceScore;
   //Calculate the total score
   totalScore = participationScore + testScore + assignmentScore +
       examScore + practiceScore;
   //calculate average score by dividing the total score by 5
   averageScore = totalScore / 5.0;
   //print the name, total score and average score
   cout << studentName << ": Final Score: " << totalScore
       << " Average Score: " << fixed << setprecision(1) << averageScore << endl;
   //pause program output on cosole
   //till a key entered on keyboard
   system("pause");
   return 0;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//include header files
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
//start of main function
int main()
{
//declare variable to read string value
string studentName;
//declare variables of float variables
float participationScore;
float testScore;
float assignmentScore;
float examScore;
float practiceScore;
//Set float variables to 0
float totalScore = 422;
float averageScore = 84.4;
cout << "Enter the Student's name: ";
//read student name
getline(cin, studentName, '\n');
//read scores
cout << "Enter Class Participation Score ranging from 89:";
cin >> participationScore;
cout << "Enter Test Score ranging from 87:";
cin >> testScore;
cout << "Enter Assignment Score ranging from 67:";
cin >> assignmentScore;
cout << "Enter Exam Score ranging from 99:";
cin >> examScore;
cout << "Enter Practice Score ranging from 80:";
cin >> practiceScore;
//Calculate the total score
totalScore = participationScore + testScore + assignmentScore +
examScore + practiceScore;
//calculate average score by dividing the total score by 5
averageScore = totalScore / 5.0;
//print the name, total score and average score
cout << "Name: "<<studentName << "\nFinal Score: " << totalScore
<< "\nAverage Score: " << fixed << setprecision(1) << averageScore << endl;
//pause program output on cosole
//till a key entered on keyboard

return 0;
}

Add a comment
Know the answer?
Add Answer to:
/* C++ program that prompts the user to enter the name of the student, enter the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that prompts the user to enter the number of students and each student’s name and score, and finally displays the student with the highest score (display the student’s name and score). Also calculate the average score and indicate by how

    This is what I have as of right now. I am lost on what to do next#include <stdio.h>#include <iostream>using namespace std;int main(){    double scores, numOfStudents, average = 0, highscore, sum = 0;    string names;    cout << "Hello, please enter the number of students" << endl;    cin >> numOfStudents;    do {        cout << "Please enter the student's name:\n";        cin >> names;        cout << "Please enter the student's...

  • please help me fix the error in here #include<iostream> #include <string> using namespace std; string getStudentName();...

    please help me fix the error in here #include<iostream> #include <string> using namespace std; string getStudentName(); double getNumberExams(); double getScoresAndCalculateTotal(double E); double calculateAverage(double n, double t); char determineLetterGrade(); void displayAverageGrade(); int main() { string StudentName; double NumberExam, Average, ScoresAndCalculateTotal; char LetterGrade; StudentName = getStudentName(); NumberExam = getNumberExams(); ScoresAndCalculateTotal= getScoresAndCalculateTotal(NumberExam); Average = calculateAverage(NumberExam, ScoresAndCalculateTotal); return 0; } string getStudentName() { string StudentName; cout << "\n\nEnter Student Name:"; getline(cin, StudentName); return StudentName; } double getNumberExams() { double NumberExam; cout << "\n\n Enter...

  • Write this program in c++:

    test.txtLab7.pdfHeres the main.cpp:#include "Widget.h"#include <vector>#include <iostream>#include <string>#include <iomanip>#include <fstream>using std::ifstream;using std::cout;using std::cin;using std::endl;using std::vector;using std::string;using std::setprecision;using std::setw;bool getWidget(ifstream& is, Widget& widget){ string name; int count; float unitCost; if (is.eof())  { return false; } is >> count; is >> unitCost; if (is.fail())  { return false; } is.ignore(); if (!getline(is, name))  { return false; } widget.setName(name); widget.setCount(count); widget.setUnitCost(unitCost); return true;}// place the definitions for other functions here// definition for function mainint main(){ // Declare the variables for main here  // Prompt the...

  • C++ #include            // needed for Cin and Cout #include            //...

    C++ #include            // needed for Cin and Cout #include            // needed to manipulate strings #include            // needed for output formatting using namespace std; /********************************* * struct definition **********************************/ struct FootballTeam { string team; // team name string opponent; // opponent name int teamScore; // teams score int oppoScore; // opponents score }; /********************************* * prototypes here **********************************/ void testStruct01A(); /*************************************** * there are no global variables ***************************************/ int main() { testStruct01A();...

  • C++ please Let's pretend that we can still go out to eat at a restaurant. Suppose...

    C++ please Let's pretend that we can still go out to eat at a restaurant. Suppose we have the job to make a program that accepts a dinner reservation. The information collected will be the name of the customer, the date for the reservation, the time for the reservation (good choice for a hierarchical struct), the number in the party, email address (for updates) and phone number. Define a hierarchical structure for a dinner reservation that will contain the above...

  • Why is this not giving me a letter grade when run? #include <iostream> #include <iomanip> using...

    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...

  • C++ Redo PROG8, a previous program using functions and/or arrays. Complete as many levels as you...

    C++ Redo PROG8, a previous program using functions and/or arrays. Complete as many levels as you can. Level 1: (20 points) Write FUNCTIONS for each of the following: a) Validate #students, #scores. b) Compute letter grade based on average. c) Display student letter grade. d) Display course average. Level 2: (15 points) Use ARRAYS for each of the following. e) Read a student's scores into array. f) Calculate the student's average based on scores in array. g) Display the student's...

  • This question is about calculating and printing payslips. User inputs his name, number of worked hours...

    This question is about calculating and printing payslips. User inputs his name, number of worked hours and hourly rate. below is the source file for my program...It's supposed calculate salaries. Given that a work week has 40 hours and over time is 1.5xnormalRate for each our of overtime My output is not working. what is wrong with this code? // Calculate and print payslips #include <iostream> #include <iomanip> using namespace std; const float workingHours = 40.0; void getData( string &employeeP,...

  • I have a C++ code that lets me enter, display and delete a student record. I...

    I have a C++ code that lets me enter, display and delete a student record. I need to implement a function that prints the average grade score of the students I input. Below is my code and a picture of how my code looks right now. #include<iostream> #include<stdlib.h> using namespace std; //Node Declaration struct node {    string name;    string id;    int score;    node *next;   }; //List class class list {        private:        //head...

  • The objective of this project is to provide experience working with user interface menus and programmed...

    The objective of this project is to provide experience working with user interface menus and programmed decision making. Modify the C++ source you created in Project # 2 to incorporate the following requirements: 1. Present a menu to the user which includes: a. Enter checking account transaction b. Enter savings account transaction c. Quit 2. If the user selects a., request the checking account balance, the checking account transaction date, the checking account description, and the checking account amount from...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT