Question

Write a c++ program that does the following: in main() 1. prompts for a student's name...

Write a c++ program that does the following:

in main()

1. prompts for a student's name (with spaces_

2. prompts for 3 grades

3. Calls a function to calculate the average of the 3 grades

- arguments must be passed by value

3. displays the student's name and average grade

- example: Fred Smith : 85.5

- the average should be a float displaying 1 digit of precision

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

Program:

#include <iostream>

#include<iomanip>

using namespace std;

float average(float g1,float g2,float g3); // function proto type

int main() {

char studentName[50]; // char array declaration

float g1,g2,g3; // integer variable declaration

cout << setprecision(1) << fixed; // set precision as 1

cout<<"Enter name of the student:";

cin.get(studentName,50); // Acept the name

cout<<"Enter 3 student grades:\n";

cin>>g1>>g2>>g3; // Accept three grades

cout<<studentName<<":"<<average(g1,g2,g3)<<endl; // calling function

}

float average(float g1,float g2,float g3) // called function

{

return (g1+g2+g3)/3; // return average

}

Output:

Add a comment
Know the answer?
Add Answer to:
Write a c++ program that does the following: in main() 1. prompts for a student's name...
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
  • C++ program Write a program that does the following: n main0 1. Prompts the user to...

    C++ program Write a program that does the following: n main0 1. Prompts the user to enter the height, length, and depth of a cube 2. Calls a function that will reduce the size of the height, length, and depth by half (ie. divide them each by 2 arguments must be passed using references handle possible resulting decimal values (ie. 3/2-1.5) 3. Calls another function that will calculate and return the volume of the 'reduced' cube -arguments must be passed...

  • in c++ A: Write a program which ask user to enter 10 student's name and their...

    in c++ A: Write a program which ask user to enter 10 student's name and their grades. Then find the average of all the grades. Output all the grades with student name of whom got the grade over the average.

  • C++ Program Int Main First Please Write one program that does the following: 1.       1.   Ask the...

    C++ Program Int Main First Please Write one program that does the following: 1.       1.   Ask the user for ten (10) grades, and store the data in an array.  Compute the average of all the grades.  Print the original ten grades and the average. a.       Declare an integer array with the name of “grades” of size 10 in the main function. b.      Create a function called “getGrades” that prompts the User for the grades and puts them in an integer array.                                                                i.      The function will receive...

  • Design a modular program using pseudo-code which prompts a user for their first name, followed by...

    Design a modular program using pseudo-code which prompts a user for their first name, followed by their last name; then displays a "Hello" salutation which concatenates their first name with their last name. Sample output (user input shown in red): Please enter your first name: John Please enter your last name: Smith Hello, John Smith! Your program must include a main module and one function; this function prompts the user for either their first name or last name, using a...

  • Help me write the program in C++ Thanks Program #1: Calculate a student's grade for a...

    Help me write the program in C++ Thanks Program #1: Calculate a student's grade for a class. The class has 4 categories of grades. Each category has different weights. The student's report should include the student's first and last name; course; semester, category listing with weight for each category, grades for each category and the student's final average with a letter grade. Categories with weights: 1. Exams: 30%(3 @ 10% each) 2. Labs: 30% (3 labs @ 10% cach) 3....

  • Q3: Write a Python program the prompts the user for information for stu num students. For...

    Q3: Write a Python program the prompts the user for information for stu num students. For each student prompt for the student ID and three quiz grades. Use a nested loop, where the inner loop prompts for the three quiz grades. Print the student's name and average, formatted to two decimal places. The sample output below is when stu_num -3. Enter name of student 1 Mary Jones Enter Score 1: 78 Enter soore 2: 90 Enter soore 3: 91 Name:...

  • 1. Palindrome Write a program that prompts the user for a positive integer number and output whet...

    Language is C 1. Palindrome Write a program that prompts the user for a positive integer number and output whether the number is a palindrome or not. A palindrome number is a number that is the same when reversed. For example, 12321 is a palindrome; 1234 is not a palindromoe. You will write a function named as palindrome. The function will have two arguments, number and isPalindrome. Both arguments are pass-by-reference. The argument number is a pointer to a variable...

  • Using the following parallel array and array of vectors: // may be declared outside the main...

    Using the following parallel array and array of vectors: // may be declared outside the main function const int NUM_STUDENTS =3; // may only be declared within the main function string Students[NUM_STUDENTS] = {"Tom","Jane","Jo"}; vector <int> grades[NUM_STUDENTS] {{78,98,88,99,77},{62,99,94,85,93}, {73,82,88,85,78}}; Write a C++ program to run a menu-driven program with the following choices: 1) Display the grades 2) Add grade 3) Remove grade for all students for a selected assignment 4) Display Average for each student 5) Display the name of...

  • Write a C++ program that computes student grades for an assignment as a percentage given each...

    Write a C++ program that computes student grades for an assignment as a percentage given each student's score and the total points. The final score must be rounded up to the nearest whole value using the ceil function in the <cmath header file and displayed as a percentage. You must also display the floating-point result up to 5 decimal places. You must use at least 2 functions: one to print the last name of the student and another function to...

  • Write a program that prompts the user for student grades, calculates and displays the average grade...

    Write a program that prompts the user for student grades, calculates and displays the average grade in the class. The user should enter a character to stop providing values.

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
ADVERTISEMENT