473,396 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help with code

32
I have most of my code I just need help with these last 2.

3. Define a function validScore that, passed a score, returns true if the score is between 0 and 100 and otherwise returns false. Using this function, modify the loop that reads in the scores so that, if the score is not valid, it is echoed with a message saying that the score is invalid, and so that the score is counted and added to the sum only when it is valid. (Note that there is some redundancy as validScore is used here since the loop exits when a negative score is entered—so validScore is never passed a score that is invalid because it is negative.)
4. Define a function letterGrade that, passed a valid score (one between 0 and 100), returns a letter grade according to the following schedule:
‘A’: 90 and above
‘B’: 80-89
‘C’: 70-79
‘D’: 60-69
‘F’: below 60
Use this function to find the letter grade corresponding to each valid score and output the letter grade as soon as it is found. Keep a count of the number of each letter grade (‘A’-‘F’) and output each count at the end of the run.

Expand|Select|Wrap|Line Numbers
  1. #include<iostream>
  2. using namespace std;
  3. int main() {
  4.  int countScores = 0;
  5.  int sumScores = 0; 
  6.  cout <<"Enter score"<< endl;
  7.  int n = 0;
  8.  cin>>n;
  9.  
  10. funct average(int score1, score2, score3)
  11. {
  12.     cout<< “Enter score1”<<endl;
  13.     cout<<”Enter score2”<<endl;
  14.     cout<<”Enter score3”<<endl;
  15.  
  16. average = (score1 + score2 + score3)/3;
  17.  
  18. return average;
  19. }
  20.  
  21.  
  22.  
  23.  while(n >= 0) {
  24.   sumScores = sumScores + n;
  25.   countScores++;
  26.   cin>>n;
  27.  }
  28.  cout<<"You entered "<<countScores<<" numbers"<<endl;
  29.  cout<<"Their sum is :"<<sumScores<<endl;
  30.  cout << “The average score is:”<<endl;
  31.  
  32.  return 0;
  33. }
Feb 1 '07 #1
1 967
Ganon11
3,652 Expert 2GB
What work have you done on these 2 parts? What ideas do you have on solving them?

Try starting by reading the problem specifications and pulling out the important information - for example, on part 4 you may note that:

1) You need a function computeGrade
2) This function will take a single integer parameter
3) Its return type is char
4) What character should be returned, based on the integer parameter
Feb 1 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: PHPkemon | last post by:
Hi there, A few weeks ago I made a post and got an answer which seemed very logical. Here's part of the post: PHPkemon wrote: > I think I've figured out how to do the main things like...
6
by: d.warnermurray | last post by:
I am doing a project for school that involves creating help files for a html authoring tool. If you could help me with answers to some questions it would really help. 1. What tasks do you expect...
6
by: Mark Reed | last post by:
Hi all, I am trying to learn a little about programming (I know next to nothing so far) and have found some code which hides the toolbars. However, this bit of code is a little too effective and...
4
by: dixie | last post by:
Help, I'm really out of my depth here (not unusual I hear you say :-). I have just installed HTML Help in an application. I told it in the Project Properties the path to the help file. I then...
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
16
by: Allen | last post by:
I have a class that returns an arraylist. How do I fill a list box from what is returned? It returns customers which is a arraylist but I cant seem to get the stuff to fill a list box. I just...
3
by: inkexit | last post by:
I need help figuring out what is wrong with my code. I posted here a few weeks ago with some code about creating self similar melodies in music. The coding style I'm being taught is apparently a...
1
by: glenn123 | last post by:
Hi, i am just about out of time to produce a working jukebox which has to perform these functions: to play music files when a track is chosen from a list which when the user presses the change genre...
10
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.