Question

In: Computer Science

Get all homework scores for one student, calculate and display the sum of the scores, and...

Get all homework scores for one student, calculate and display the sum of the scores, and also display the word “fail” if the sum is lower than 150. Note: we do not know how many homework scores each student will enter.

Ask the user how many homework scores there are at the beginning. Then, ask for a homework score at a time, for as many times as indicated by the user.

C++

Solutions

Expert Solution

C++ Code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
//n stores count of homework scores

int score;
//score stores current homework score

int tot_score=0;
//tot_score stores total score of the student(initialised to 0)
  
for(int i=0;i<n;i++)
{
cin>>score;
tot_score+=score;
}

//print total score
cout<<tot_score<<endl;

//print "fail" if total score is less than 150
if(tot_score<150)
cout<<"fail"<<endl;
}

Screenshots and Results:


Related Solutions

write a program that will display student grade if scores is greater than or equal to...
write a program that will display student grade if scores is greater than or equal to 70 to display A or else if score is less than or equal to 70 and greater than or equal to 60 display B if scores is less than 60 or greater than 50 display C else display fail.
1. For each vendor display the vendor name, sum of all orders as Total Value and...
1. For each vendor display the vendor name, sum of all orders as Total Value and the number of orders placed as # Orders. Hint you must calculate the total amount for each order based upon unit price and number of units ordered. Write SQL Query 2.    Display the name of vendors who have supplied at least one order to every event.   Hint this query will require nested correlated subqueries using the not exists operator. Write SQL query
how do you get the sum of all elements in a stack in c++ ?
how do you get the sum of all elements in a stack in c++ ?
The mean serves as the balance point for any distribution because the sum of all scores,...
The mean serves as the balance point for any distribution because the sum of all scores, expressed as positive and negative distances from the mean, always equals zero. (a) Show that the mean possesses this property for the following set of scores: 3, 6, 2, 0, 4. (b) Satisfy yourself that the mean identifies the only point that possesses this property. More specifically, select some other number, preferably a whole number(for convenience), and then find the sum of all scores...
Calculate the Net Promoter Score (NPS) given the following: a) Sum of "Promoter Scores" = 245...
Calculate the Net Promoter Score (NPS) given the following: a) Sum of "Promoter Scores" = 245 b) Sum of "Passive Scores"= 205 c) Sum of "Detractors Scores" = 150
Input 10 integers and display the following: a. the sum of even numbers. b. the sum...
Input 10 integers and display the following: a. the sum of even numbers. b. the sum of odd numbers. c. the largest integer d. the smallest integer e. the total count of even numbers f. the total count of odd numbers. Using C++ program with for loop..
Homework 4: Probability and z scores Use the data to answer the following questions Show all...
Homework 4: Probability and z scores Use the data to answer the following questions Show all work (*round 2 decimals places) What is the mean & SD for the distribution of scores? What is the corresponding z score for each raw score? What is the probability of getting a raw score greater than 4? What is the probability of getting a raw score less than 2? What is the probability of a raw score between 4 & 6? What is...
How to get the percent of scores in one and two standard deviations of the mean
How to get the percent of scores in one and two standard deviations of the mean
Review these questions and scenarios: a student copies a homework, is that cheating? If a student...
Review these questions and scenarios: a student copies a homework, is that cheating? If a student edits a paper that was written by another in a previous term and submits it as his/her own, is that a problem? Is it okay for a student who forgot to check the patient's CBC and instead fills in a number that s/he thinks is good on the care plan? It is absolutely acceptable for students to have their papers proof read. Describe the...
suppose 10 students get A's, 2 Students get B's 3 Students get C's, and one student...
suppose 10 students get A's, 2 Students get B's 3 Students get C's, and one student gets an F If a committee is formed with 3 people, what is the probability that there are two people with an A and 1 with a C? What is the probability of selecting a grade A student for the first time on either the 2nd or 3rd selection?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT