Skip to content

Instantly share code, notes, and snippets.

@CarbonHeartDev
Created January 13, 2022 22:33
Show Gist options
  • Save CarbonHeartDev/20bff10fc4ae25d4aa093ded90d3f1da to your computer and use it in GitHub Desktop.
Save CarbonHeartDev/20bff10fc4ae25d4aa093ded90d3f1da to your computer and use it in GitHub Desktop.
Esercizio risolto per skuola.net
#include <iostream>
using namespace std;
int main()
{
int numero_persone;
float prezzo_totale_bus, prezzo_a_persona_treno;
cout << "Inserire il numero di persone ";
cin >> numero_persone;
cout << "Inserire il prezzo totale del bus ";
cin >> prezzo_totale_bus;
cout << "Inserire il prezzo a persona del treno ";
cin >> prezzo_a_persona_treno;
float prezzo_totale_treno = numero_persone * prezzo_a_persona_treno;
if(prezzo_totale_bus < prezzo_totale_treno){
cout << "La scelta piu' conveniente e' il bus";
} else if (prezzo_totale_bus == prezzo_totale_treno) {
cout << "Bus e treno hanno lo stesso prezzo";
} else {
cout << "La scelta piu' conveniente e' il treno";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment