Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Esercizio N°28 v0.2 Alessandro Mieli 16/01/2018
- #include <iostream>
- #include <conio.h>
- using namespace std;
- /*
- Fare un programma in C++ che stampi la media di uno studente se ha un’età compresa tra 15 e 17 anni.
- Provare successivamente a calcolare la media voti di tre studenti e a stampare solo quelle superiori a 7.5.
- */
- int main() {
- int eta,i,j,n;
- float b,a;
- for(i=0;i<3;i++) {
- system("CLS");
- cout << "\t\tStudente " << i + 1 << "\n\nInserisci la tua eta': ";
- cin >> eta;
- if(eta >= 15 && eta <= 17) {
- b = 0;
- a = 0;
- cout << "\nSu quante materie calcolare la media: ";
- cin >> n;
- for(j=0;j<n;j++) {
- cout << "\nInserisci il voto della " << j + 1 << " materia: ";
- cin >> a;
- if(a < 0 || a > 10) {
- cout << "Errore...\n";
- j--;
- }else
- b += a;
- }
- if(b/n < 7.5)
- cout << "\nLa tua media non e' superiore al 7.5!";
- else
- cout << "\nHai la media del " << b/n << "!\nPremere un tasto per continuare";
- getch();
- }else {
- cout << "\nNon hai l'eta' giusta per visualizzare questi contenuti...\nPremere un tasto per continuare";
- getch();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement