Chapter # 8 (Arrays) Problem 1 1. Histogram Generate a text-based histogram for a sequence of grades to a class of students. The grades are l'A'- 'D', 'F'). Write a program that allows the user to enter grades of students in upper/lower case. As the grades are being entered, the program should count, using an array, the number of A's, the number of B's, the number of C's, the number of D's, and the number of F's. The program should be capable of handling an arbitrary number of student grades. However, the input should end when an invalid grade is encountered. To design your counters, use an array of size 5 where each array element is initialized to zero. Whenever an 'A" or 'a' is entered, increment array[0). Whenever a 'B' or 'b' is entered, increment array[1), etc. up to array[4]. Output the histogram count and the bar- chart too as shown below. Sample input / output: Enter sequence of valid grade ['A'-'F'] ending with an invalid grade to stop: 6BBC CA a a AdDDd afFFBa Ade 7 grade(s) of A ; bar-chart: ***** 4 grade(s) of B; bar-chart: *** 2 grade(s) ofC; bar-chart: ** 5 grade(s) ofD; bar-chart: ***** 5 grade(s) of F; bar-chart: *** Enter sequence of valid grade ['A'-'F'] ending with an invalid grade to stop: abcdfdbbBBAcDffFFFp 2 grade(s) of A ; bar-chart: * 5 grade(s) of B; bar-chart: ***** 2 grade(s) of C; bar-chart: ** 3 grade(s) of D; bar-chart: *** 5 grade(s) of F; bar-chart: ***

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%
Chapter # 8 (Arrays)
Problem 1
1. Histogram
Generate a text-based histogram for a sequence of grades to a class of students. The grades are l'A'-
'D', 'F'). Write a program that allows the user to enter grades of students in upper/lower case. As
the grades are being entered, the program should count, using an array, the number of A's, the
number of B's, the number of C's, the number of D's, and the number of F's. The program should be
capable of handling an arbitrary number of student grades. However, the input should end when an
invalid grade is encountered. To design your counters, use an array of size 5 where each array
element is initialized to zero. Whenever an 'A" or 'a' is entered, increment array[0]. Whenever a 'B'
or 'b' is entered, increment array[1], etc. up to array[4]. Output the histogram count and the bar-
chart too as shown below.
Sample input / output:
Enter sequence of valid grade ['A'-'F'] ending with an invalid grade to stop:
b BBc CA a a Ad DDda FFFBA A d e
7 grade(s) of A ; bar-chart: *******
4 grade(s) of B; bar-chart: ****
2 grade(s) of C; bar-chart: **
5 grade(s) of D; bar-chart: *****
5 grade(s) of F ; bar-chart: ***
Enter sequence of valid grade ['A'-'F'] ending with an invalid grade to stop:
abcdfdbbBBAcDffFFFp
2 grade(s) of A ; bar-chart: **
5 grade(s) of B; bar-chart: *****
2 grade(s) of C; bar-chart: **
3 grade(s) of D ; bar-chart: ***
5 grade(s) of F; bar-chart: ******
Transcribed Image Text:Chapter # 8 (Arrays) Problem 1 1. Histogram Generate a text-based histogram for a sequence of grades to a class of students. The grades are l'A'- 'D', 'F'). Write a program that allows the user to enter grades of students in upper/lower case. As the grades are being entered, the program should count, using an array, the number of A's, the number of B's, the number of C's, the number of D's, and the number of F's. The program should be capable of handling an arbitrary number of student grades. However, the input should end when an invalid grade is encountered. To design your counters, use an array of size 5 where each array element is initialized to zero. Whenever an 'A" or 'a' is entered, increment array[0]. Whenever a 'B' or 'b' is entered, increment array[1], etc. up to array[4]. Output the histogram count and the bar- chart too as shown below. Sample input / output: Enter sequence of valid grade ['A'-'F'] ending with an invalid grade to stop: b BBc CA a a Ad DDda FFFBA A d e 7 grade(s) of A ; bar-chart: ******* 4 grade(s) of B; bar-chart: **** 2 grade(s) of C; bar-chart: ** 5 grade(s) of D; bar-chart: ***** 5 grade(s) of F ; bar-chart: *** Enter sequence of valid grade ['A'-'F'] ending with an invalid grade to stop: abcdfdbbBBAcDffFFFp 2 grade(s) of A ; bar-chart: ** 5 grade(s) of B; bar-chart: ***** 2 grade(s) of C; bar-chart: ** 3 grade(s) of D ; bar-chart: *** 5 grade(s) of F; bar-chart: ******
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY