Mi è stato dato questo esercizio da fare per scuola, qualcuno può aiutarmi che io non ne sono in grado?

di il
23 risposte

Mi è stato dato questo esercizio da fare per scuola, qualcuno può aiutarmi che io non ne sono in grado?

Questo è l'esercizio che mi è stato dato:


A. Programming task:
The University wantsto make a basic graphical display to show how many people received different
gradesfor a piece of work on a module. You are required to write a program in C++ that achieves this.
The specification of the program is given below.
Specification
1. The program should allow the tutor to enter the various marks which the students have been
awarded, until the tutor enters a mark exceeding 100.
At this point the program should display a histogram using stars. Each star represents a student
who achieved a module mark in the range shown below.
You will find an example of the program output below. The example below shows the distribution
of marksfor 20 students. Your program should work with any number of student marks entered.
Example output:
0-29 ***
30-39 *****
40-69 ********
70-100 ****
20 students in total.
2. As the tutor enters each mark, a counter should count the number ofmarks which have been
entered per student.
Use four categories for mark range: 0-29, 30-39, 40-69, 70-100
2 | Page
3. Make sure the display is neatly formatted as in the example above.
4. Your program should make use of ‘loops’ for the display of each category.
5. After the histogram, a variety of statisticsshould be displayed such as: average mark awarded,
number of students passing, highest mark, and lowestmark


QUESTO è IL MIO LAVORO:


#include <iostream>
using namespace std;

int Mark, Rage1, Rage2, Rage3, Rage4 = 0;

int main() {
while (Mark <= 100) {
cout << "Enter Mark:"; cin >> Mark;
if (Mark >= 0 & Mark <= 29) {
Rage1++;
}
else if (Mark >= 30 & Mark <= 39) {
Rage2++;
}
else if (Mark >= 40 & Mark <= 69) {
Rage3++;
}
else if (Mark >= 70 & Mark <= 100) {
Rage4++;
}

char i;
i = 0;
for (i = "*"; i = Rage1; i++)
cout << "0-29" "i" << endl;
for (i = "*"; i = Rage2; i++)
cout << "30-39" "i" << endl;
for (i = "*"; i = Rage3; i++)
cout << "40-69" "i" << endl;
for (i = "*"; i = Rage4; i++)
cout << "70-100" "i" << endl;
}

return 0;
}

SE QUALCUNO FOSSE COSì GENTILE DA DIRMI DOVE HO SBAGLIATO E COME CORREGGERLO NE SAREI MOLTO FELICE.

23 Risposte

Devi accedere o registrarti per scrivere nel forum
23 risposte