1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
blagie [28]
3 years ago
9

Develop a C program that calculates the final score and the average score for a student from his/her (1)class participation, (2)

test, (3) assignment, (4) exam, and (5) practice scores. The program should use variables, cout, cin, getline(), type casting, and output manipulators. The user should enter the name of the student and scores ranging from 0 to 100 (integer) for each grading item. The final score is the sum of all grading items. The average score is the average of all grading items.
Computers and Technology
1 answer:
Ghella [55]3 years ago
8 0

Answer:

#include <iomanip>

#include<iostream>

using namespace std;

int main(){

char name[100];

float classp, test, assgn, exam, prctscore,ave;

cout<<"Student Name: ";

cin.getline(name,100);

cout<<"Class Participation: "; cin>>classp;

while(classp <0 || classp > 100){  cout<<"Class Participation: "; cin>>classp; }

cout<<"Test: "; cin>>test;

while(test <0 || test > 100){  cout<<"Test: "; cin>>test; }

cout<<"Assignment: "; cin>>assgn;

while(assgn <0 || assgn > 100){  cout<<"Assignment: "; cin>>assgn; }

cout<<"Examination: "; cin>>exam;

while(exam <0 || exam > 100){  cout<<"Examination: "; cin>>exam; }

cout<<"Practice Score: "; cin>>prctscore;

while(prctscore <0 || prctscore > 100){  cout<<"Practice Score: "; cin>>prctscore; }

ave = (int)(classp + test + assgn + exam + prctscore)/5;

cout <<setprecision(1)<<fixed<<"The average score is "<<ave;  

return 0;}

Explanation:

The required parameters such as cin, cout, etc. implies that the program is to be written in C++ (not C).

So, I answered the program using C++.

Line by line explanation is as follows;

This declares name as character of maximum size of 100 characters

char name[100];

This declares the grading items as float

float classp, test, assgn, exam, prctscore,ave;

This prompts the user for student name

cout<<"Student Name: ";

This gets the student name using getline

cin.getline(name,100);

This prompts the user for class participation. The corresponding while loop ensures that the score s between 0 and 100 (inclusive)

<em> cout<<"Class Participation: "; cin>>classp; </em>

<em> while(classp <0 || classp > 100){  cout<<"Class Participation: "; cin>>classp; } </em>

This prompts the user for test. The corresponding while loop ensures that the score s between 0 and 100 (inclusive)

<em> cout<<"Test: "; cin>>test; </em>

<em> while(test <0 || test > 100){  cout<<"Test: "; cin>>test; } </em>

This prompts the user for assignment. The corresponding while loop ensures that the score s between 0 and 100 (inclusive)

<em> cout<<"Assignment: "; cin>>assgn; </em>

<em> while(assgn <0 || assgn > 100){  cout<<"Assignment: "; cin>>assgn; } </em>

This prompts the user for examination. The corresponding while loop ensures that the score s between 0 and 100 (inclusive)

<em> cout<<"Examination: "; cin>>exam; </em>

<em> while(exam <0 || exam > 100){  cout<<"Examination: "; cin>>exam; } </em>

This prompts the user for practice score. The corresponding while loop ensures that the score s between 0 and 100 (inclusive)

<em> cout<<"Practice Score: "; cin>>prctscore; </em>

<em> while(prctscore <0 || prctscore > 100){  cout<<"Practice Score: "; cin>>prctscore; } </em>

This calculates the average of the grading items

ave = (int)(classp + test + assgn + exam + prctscore)/5;

This prints the calculated average

cout <<setprecision(1)<<fixed<<"The average score is "<<ave;  

You might be interested in
Tell me at list 5 farm animals dieases​
Vlad [161]
<h3>Answer : </h3>

<em><u>F</u></em><em><u>a</u></em><em><u>r</u></em><em><u>m</u></em><em><u> </u></em><em><u>C</u></em><em><u>o</u></em><em><u>m</u></em><em><u>m</u></em><em><u>o</u></em><em><u>n</u></em><em><u> </u></em><em><u>D</u></em><em><u>i</u></em><em><u>s</u></em><em><u>e</u></em><em><u>a</u></em><em><u>s</u></em><em><u>e</u></em><em><u>s</u></em><em><u> </u></em><em><u>:</u></em><em><u> </u></em>

<em><u>.</u></em><em><u> </u></em><em><u>General Farm Animal Diseases.</u></em>

<em><u>.</u></em><em><u> </u></em><em><u>Avian Influenza.</u></em>

<em><u>.</u></em><em><u> </u></em><em><u>Bovine Spongiform Encephalopathy (BSE)</u></em>

<em><u>.</u></em><em><u> </u></em><em><u>Foot-and-Mouth Disease.</u></em>

<em><u>.</u></em><em><u> </u></em><em><u>West Nile Virus.</u></em>

Explanation:

<em><u>H</u></em><em><u>o</u></em><em><u>p</u></em><em><u>e</u></em><em><u> </u></em><em><u>i</u></em><em><u>t</u></em><em><u> </u></em><em><u>h</u></em><em><u>e</u></em><em><u>l</u></em><em><u>p</u></em><em><u>s</u></em><em><u> </u></em><em><u>o</u></em><em><u>u</u></em><em><u>t</u></em><em><u> </u></em><em><u>:</u></em><em><u>)</u></em><em><u>)</u></em>

7 0
3 years ago
Read 2 more answers
(In C prog.) What is the difference between scanf, getche and getchar?
lara [203]
<span>getchar() only reads a single character input from any input stream.
getche() </span><span>reads a single character from the keyboard and displays immediately on output screen without waiting for enter key
scanf() reads the whole input line according to the data type you specified.</span>

7 0
3 years ago
PLEASE HELP SOMEONE!!!!!!!!! WILL GIVE BRAINLIEST!!!!!!!!!!!!!!!!!!!!!!!!! Fill in the blanks.
olasank [31]
<span> change the behavior of the program I think</span>
7 0
3 years ago
• R7.9 Write enhanced for loops for the following tasks.
alexdok [17]

Answer:

a is the correct answer

Explanation:

correct me if I'm wrong hope it's help thanks

3 0
3 years ago
Which approach does procedural programming follow? bottom up, top down, random, or object oriented​
ELEN [110]

Answer:

Top to down approach

Explanation:

7 0
3 years ago
Other questions:
  • To move to the bottom of a document window, press the ____ key(s). ALT CTRL PAGE DOWN CTRL PAGE DOWN ALT PAGE DOWN PAGE DOWN
    11·1 answer
  • To prevent unauthorized access and use, at a minimum a company should have a written __________ that outlines the activities for
    6·1 answer
  • What is the subnet mask ?
    9·2 answers
  • 2. (8 points) When creating the Academic Database, there were several instances of data
    11·1 answer
  • How do the companies gather data to determine common passwords?
    13·1 answer
  • How does an individual's access to a wide range of online services affects their ability to operate safely in the digital world.
    5·1 answer
  • Define the instance method inc_num_kids() for PersonInfo. inc_num_kids increments the member data num_kids. Sample output for th
    6·1 answer
  • Question # 1
    12·2 answers
  • You are a teaching assistant for an introductory computer concepts course at your local community college. The instructor asks y
    11·1 answer
  • Bluetooth is the popular name for the 802. 15 wireless networking standard, which is useful for creating small __________.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!