Question

Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that...

Using basic c++ write 2 separate codes for this assignment.

Program #1 Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions.

• void getScore() should ask the user for a test score, store it in the reference parameter variable, and validate it. This function should be called by the main once for each of the five scores to be entered.

• void calcAverage() should calculate and display the average of the four highest scores. The functions should be called just once by main and should be passed the five scores.

• int findLowest() should find and return the lowest of the five scores passed to it. It should be called by calcAverage, which uses this function to determine which of the five scores to be dropped.

• Function prototypes void getScore(int &); void calcAverage(int, int, int, int, int); int findLowest(int, int, int, int, int);

Input Validation: Do not accept test scores lower than 0 or higher than 100

Program #2 Write a program to calculate the frequency of occurrence of each letter in a given text file. Your program should not distinguish between lower case and upper case letters. The text may contain characters other than alphabets. You can ignore the non-alphabetic characters. Write a function to convert all the uppercase letters to lowercase letters and use it. Your output should display for each letter the frequency of its occurrence in the file. A sample output is shown below.

Letter ‘a’ occurred 20 times

Letter ‘b’ occurred 25 times

.

.

.

Letter ‘z’ occurred 10 times The program should output the number of occurrences of a letter, only if the letter occurs at least once in the input file. In other words, if a letter did not occur in the input file, the program should not display that the occurred 0 times. Assume the name of the input file to be “fileread.txt”. I have attached the file to you along with the assignment. This will ensure all the students got same answers.

Prompt the user to enter the name of the input file and process the input file.

Hint: use an array and map each letter to an index of the array.

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

#include <iostream>
using namespace std;
void getScore(int&);
void calcAverage(int,int,int,int,int);
int findLowest(int,int,int,int,int);
int main()
{int n1,n2,n3,n4,n5;
getScore(n1);
getScore(n2);
getScore(n3);
getScore(n4);
getScore(n5);
calcAverage(n1,n2,n3,n4,n5);
return 0;
}
void getScore(int& num)
{do
{cout<<"enter a number: ";
cin>>num;
if(num<0||num>100)
cout<<"number out of range-try again\n";
}while(num<0||num>100);
return;
}
void calcAverage(int n1,int n2,int n3,int n4,int n5)
{double average;
int low,total;
low=findLowest(n1,n2,n3,n4,n5);
total=n1+n2+n3+n4+n5-low;
average=total/4.;
cout<<"The average of the top 4 grades is "<<average<<endl;
return;
}

int findLowest(int n1,int n2,int n3,int n4,int n5)
{int low;
low=n1;
if(n2<low)
low=n2;
if(n3<low)
low=n3;
if(n4<low)
low=n4;
if(n5<low)
low=n5;
return low;
}

Add a comment
Know the answer?
Add Answer to:
Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that...
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
  • I need help with this c++ question please thank you ltls. The program should urt valte....

    I need help with this c++ question please thank you ltls. The program should urt valte. 11. Lowest Score Drop Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: void getscore() should ask the user for a test score, store it in a reference param- eter variable, and validate it. This function should be called by main once for each of...

  • Lowest Score Drop In Functions, there can only be one return statement. You can not use...

    Lowest Score Drop In Functions, there can only be one return statement. You can not use an exit or break function. Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: void getScore() should ask the user for a test score, store it in a reference parameter variable, and validate it. This function should be called by main once for each of...

  • C Program In this assignment you'll write a program that encrypts the alphabetic letters in a...

    C Program In this assignment you'll write a program that encrypts the alphabetic letters in a file using the Vigenère cipher. Your program will take two command line parameters containing the names of the file storing the encryption key and the file to be encrypted. The program must generate output to the console (terminal) screen as specified below. Command Line Parameters Your program must compile and run from the command line. The program executable must be named “vigenere” (all lower...

  • c plus plus determines which of 5 geographic regions within a major city north south east...

    c plus plus determines which of 5 geographic regions within a major city north south east west and central had the fewest reported traffic accidents last year it should have the following function which are called by main int get NumAccidents is passed the name of a region it asks the user for the number of traffic accidents reported in that region during the last year validates the input then returns it. it should be called once for each city...

  • Topics: Arrays in C. For this assignment, you will write a C program that uses its...

    Topics: Arrays in C. For this assignment, you will write a C program that uses its first command line parameter to compute and display a histogram of characters that occur in it. Requirements: Your program must compile and run correctly using the gcc compiler on ale. You must write the corresponding function definitions for the following function prototypes: // set all elements of the histogram to zero void init_histogram(int histo[]); // construct the histogram from string void cons_histogram(char string[], int...

  • Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate...

    Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate the number of test scores the user enters; have scores fall into a normal distribution for grades -Display all of the generated scores - no more than 10 per line -Calculate and display the average of all scores -Find and display the number of scores above the overall average (previous output) -Find and display the letter grade that corresponds to the average above (overall...

  • Write a program that asks the user to enter five test scores. The program should display...

    Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Design the following functions in the program: calcAverage—This function should accept five test scores as arguments and return the average of the scores. determineGrade—This function should accept a test score as an argument and return a letter grade for the score (as a String), based on the following grading scale: Score Letter Grade...

  • A particular talent composition has 5 judges, each of whom awards a score between 0 and...

    A particular talent composition has 5 judges, each of whom awards a score between 0 and 10 to each performer. Fractional scores, such as 8.3, are allowed. A performer's final score is determined by dropping the lowest and the highest score received, then averaging the 3 remaining scores. Write a program that uses this method to calculate a contestant's score. It should include the following functions: double getJudgeData() should ask the user for a judge's score and validate the score....

  • Write a complete C program that inputs a paragraph of text and prints out each unique...

    Write a complete C program that inputs a paragraph of text and prints out each unique letter found in the text along with the number of times it occurred. A sample run of the program is given below. You should input your text from a data file specified on the command line. Your output should be formatted and presented exactly like the sample run (i.e. alphabetized with the exact spacings and output labels). The name of your data file along...

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