11.07.2015 Views

1) Que fait le programme ci-dessous

1) Que fait le programme ci-dessous

1) Que fait le programme ci-dessous

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Nom :_______________Prénom : _____________CIP 1 ère année (pair) - 24/10/20081) <strong>Que</strong> <strong>fait</strong> <strong>le</strong> <strong>programme</strong> <strong>ci</strong>-<strong>dessous</strong> ?if (a!=2)System.out.println("Gagné ");elseif (a==3)System.out.println("un instant, s.v.p.");elseSystem.out.println("perdu"); Dans <strong>le</strong>s cas où l'on aurait défini au préalab<strong>le</strong> que- a=1 :- a=2 :- a=3 :- a= 15 :2) <strong>Que</strong> <strong>fait</strong> <strong>le</strong> <strong>programme</strong> <strong>ci</strong>-<strong>dessous</strong> ?char a = 'y';int b = 2;if ((a=='y') || (b


Nom :_______________Prénom : _____________CIP 1 ère année (pair) - 24/10/20083) Ecrivez <strong>le</strong>s lignes de codes qui correspondent à :Demander à l'utilisateur son prénom et son âge. En fonction de ces données, afficher <strong>le</strong> prénomde la personne suivi de « Ce site est réservé aux majeurs » ou « Bienvenue à toi».4) Ecrivez <strong>le</strong>s lignes de codes qui correspondent à :Saisir <strong>le</strong> rang puis <strong>le</strong> nombre d’étudiants, puis à afficher l’appré<strong>ci</strong>ation d’un étudiantrelativement à l’échel<strong>le</strong> ECTS en fonction de son rang conformément au tab<strong>le</strong>au suivant :Echel<strong>le</strong> note ECTS Appré<strong>ci</strong>ation % des étudiants qui doivent obtenir lanoteA Excel<strong>le</strong>nt 10%B Très bien 25%C Bien 30%D Satisfaisant 25%E Passab<strong>le</strong> 10%Ce tab<strong>le</strong>au signifie que <strong>le</strong>s premiers 10% sont évalués comme excel<strong>le</strong>nts, <strong>le</strong>s 25% suivants sontTrès bien, etc.Exemp<strong>le</strong>s de traces d’exécution :rang : 2sur : 20Excel<strong>le</strong>nt !!rang : 5sur : 10Bienrang : 65sur : 100Bien2/6


Nom :_______________Prénom : _____________CIP 1 ère année (pair) - 24/10/20085) Compléter <strong>le</strong> code suivant :import algoprog.util.Conso<strong>le</strong>;public class Cerc<strong>le</strong> {// un cerc<strong>le</strong> est défini par// un attribut rayonprivate doub<strong>le</strong> rayon;// et deux attributs indiquant où est son centreprivate doub<strong>le</strong> absCentre, ordCentre;// un constructeur de cerc<strong>le</strong>public Cerc<strong>le</strong>(doub<strong>le</strong> <strong>le</strong>Rayon, doub<strong>le</strong> lAbsCentre, doub<strong>le</strong> lOrdCentre) {rayon = <strong>le</strong>Rayon;absCentre = lAbsCentre;ordCentre = lOrdCentre;}// <strong>le</strong>s accesseurspublic doub<strong>le</strong> getRayon() {return rayon;}public doub<strong>le</strong> getAbsCentre() {return absCentre;}public doub<strong>le</strong> getOrdCentre() {return ordCentre;}public String toString() {String s = "cerc<strong>le</strong> de rayon " + getRayon();s = s + ", son centre est en position (";s = s + getAbsCentre() + ", " + getOrdCentre() + ")";return s;}//Le périmètre d’un cerc<strong>le</strong> : 2 * Pi * rayonpublic doub<strong>le</strong> perimetre() {}3/6


Nom :_______________Prénom : _____________CIP 1 ère année (pair) - 24/10/2008public static void main(String[] args) {doub<strong>le</strong> <strong>le</strong>Rayon = Conso<strong>le</strong>.lireDoub<strong>le</strong>("Rayon du premier cerc<strong>le</strong> : ");doub<strong>le</strong> lAbs = Conso<strong>le</strong>.lireDoub<strong>le</strong>("Abs<strong>ci</strong>sse du centre : ");doub<strong>le</strong> lOrd = Conso<strong>le</strong>.lireDoub<strong>le</strong>("Ordonnée du centre : ");Cerc<strong>le</strong> monPremierCerc<strong>le</strong> = new Cerc<strong>le</strong>(<strong>le</strong>Rayon, lAbs, lOrd);System.out.println("Premier cerc<strong>le</strong> : " + monPremierCerc<strong>le</strong> + ",");System.out.println("son périmètre est" + monPremierCerc<strong>le</strong>.perimetre() +"."); //saisir <strong>le</strong>s informations relatives à un deuxième cerc<strong>le</strong> //Créer un deuxième cerc<strong>le</strong> // Ecrire un message équiva<strong>le</strong>nt à celui donné pour <strong>le</strong> premier cerc<strong>le</strong>// Calcu<strong>le</strong>r <strong>le</strong> carré de la distance entre <strong>le</strong>s centres des deux cerc<strong>le</strong>s// rappel ://distance entre deux points (x1,y1) et (x2,y2) : (x2 – x1) 2 +(y2 - y1) 2// Calcu<strong>le</strong>r <strong>le</strong> carré de la somme des rayons des deux cerc<strong>le</strong>s// Calcu<strong>le</strong>r <strong>le</strong> carré de la différence des rayons des deux cerc<strong>le</strong>s4/6


Nom :_______________Prénom : _____________CIP 1 ère année (pair) - 24/10/2008// Les cerc<strong>le</strong>s sont extérieurs l'un à l'autre// si la distance entre <strong>le</strong>s centres est supérieure à la somme des rayons,// sinon si la distance entre <strong>le</strong>s centres est inférieure à la différence// des rayons <strong>le</strong> plus petit est intérieur au plus grand,//sinon ils sont séquents.// Comparer deux nombres positifs c'est pareil que comparer <strong>le</strong>s carrés de// ces nombres.5/6


Nom :_______________Prénom : _____________CIP 1 ère année (pair) - 24/10/2008Exemp<strong>le</strong>s de traces de ce <strong>programme</strong> :Rayon du premier cerc<strong>le</strong> : 5Abs<strong>ci</strong>sse du centre : 0Ordonnée du centre : 0Premier cerc<strong>le</strong> : cerc<strong>le</strong> de rayon 5.0, son centre est en position (0.0, 0.0),Son périmètre est 31,41.Rayon du deuxième cerc<strong>le</strong> : 4Abs<strong>ci</strong>sse du centre : 10Ordonnée du centre : 0Deuxième cerc<strong>le</strong> : cerc<strong>le</strong> de rayon 4.0, son centre est en position (10.0, 0.0),Son périmètre est 25.13.<strong>le</strong>s cerc<strong>le</strong>s sont extérieurs l'un à l'autreRayon du premier cerc<strong>le</strong> : 5Abs<strong>ci</strong>sse du centre : 0Ordonnée du centre : 1Premier cerc<strong>le</strong> : cerc<strong>le</strong> de rayon 5.0, son centre est en position (0.0, 1.0),Son périmètre est 78.5Rayon du deuxième cerc<strong>le</strong> : 6Abs<strong>ci</strong>sse du centre : 0Ordonnée du centre : 0Deuxième cerc<strong>le</strong> : cerc<strong>le</strong> de rayon 6.0, son centre est en position (0.0, 0.0),Son périmètre est 36.7.<strong>le</strong>s deux cerc<strong>le</strong>s sont séquents6/6

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!