Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

complete the code in prob19.cpp that will cause this program to display the first and last name, with last name displayed first followed by a

complete the code in prob19.cpp that will cause this program to display the first and last name, with last name displayed first followed by a comma and a space followed by first name. The name should be followed on the same line by three test scores and the average of these three scores. All three tests should be random numbers between 0.0 and 100.0.. The average should be computed by adding the three scores together and dividing the total by three. Use variables to hold all values. The variable for the firstname should get its value from a random first name in the list of first names (fname) provided, and the variable for the lastname should get its value from a random last name in the list of last names (lname). Use a fourth variable to hold the concatenation of the lastname followed by a comma and space followed by the first name. Display the name, test scores and average grade so they line up under the headings that are provided in the code.. Use the variables in the output statement. Be sure to update the comments to note your name as the author and the date you completed the code. Submit your final, error-free source file (the .cpp file).

The code in C++ as follows:

/******************************************************************** * File: prob19.cpp * Author: Don Mendonsa * Version: 2020-01-11 * * Description: This progrom displays a random student name, three * randomly generated test scores and the average grade. * * Input: none * Output: console output via cout * * Example output: * Student Name Test 1 Test 2 Test 3 Grade * Johnson, John 45.6 47.9 24.9 39.5 ********************************************************************/ #include #include #include #include #include using namespace std;

// Global type definitions // Global constants // Global Variables string firstName; string lastName; float test1; float test2; float test3; float grade; string fnames[] = { "John", "Jane", "William", "Elaine", "A. B."}; string lnames[] = { "Smith", "Jones", "Williams", "Hudson", "Johnson"};

// Functions prototypes

/******************************************************************** * function: main ********************************************************************/ int main() { srand(time(NULL)); // code to set first name to a random name from list of first names // code to set last name to a random name from list of last names // code to assign test1 a random grade from 0.0 to 100.0 // code to assign test2 a random grade from 0.0 to 100.0 // code to assign test3 a random grade from 0.0 to 100.0 // code to assign the average of the 3 test grades

cout << setw(20) << left << "Student Name"; cout << " " << setw(6) << right << "Test 1"; cout << " " << setw(6) << right << "Test 2"; cout << " " << setw(6) << right << "Test 3"; cout << " " << setw(6) << right << "Grade"; cout << endl;

// code to display the lastname, firstname left justified in 20 spaces // code to display the test1 value with 1 digit to right of decimal // code to display the test2 value with 1 digit to right of decimal // code to display the test3 value with 1 digit to right of decimal // code to display the grade value with 1 digit to right of decimal cout << endl; return 0; } // Other function definitions

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

IBM Db2 11 1 Certification Guide Explore Techniques To Master Database Programming And Administration Tasks In IBM Db2

Authors: Mohankumar Saraswatipura ,Robert Collins

1st Edition

1788626915, 978-1788626910

More Books

Students also viewed these Databases questions

Question

a. Let q = q(C:end), q(1:C 1).

Answered: 1 week ago