Exercice corrige java Exercice Écrivez une classe Rectangle ? ayant deux variables a ? et b ? et une fonction membre surface ? qui retournera la surface du rectangle import java util class Rectangle public int a b public int surface return ab public class
Exercice Écrivez une classe Rectangle ? ayant deux variables a ? et b ? et une fonction membre surface ? qui retournera la surface du rectangle import java util class Rectangle public int a b public int surface return ab public class Test public static void main String args Rectangle rectangle new Rectangle Scanner in new Scanner System in System out println Entrez la largeur a du rectangle rectangle a in nextInt System out println Entrez la longueur b du rectangle rectangle b in nextInt System out println Surface rectangle surface in close Exercice Écrivez une classe Java appelée Student ? avec les membres suivant ? nom de type String ? note note de type int CLe programme demande à l ? utilisateur d ? entrer le nom et les notes calcmoy calcule la note moyenne et show a ?che le nom et la note moyenne import java util class Student public String nom public int note note Student String nom int note int note this nom nom this note note this note note public int calcmoy return note note public void show System out println Étudiant nom n moyenne calc moy public class Main public static void main String args Scanner in new Scanner System in System out println Entrez le nom String nom in nextLine System out println Entrez les notes de deux matiéres int note in nextInt int note in nextInt CStudent s new Student nom note note s show in close Exercice Créez une classe appelée Point ? Cette classe doit avoir entiers x y en tant que membres privés Le constructeur doit dé ?nir les valeurs de x et y via des paramètres La classe doit avoir une méthode publique appelée distance ? Cela prend un seul paramètre Point et renvoie la distance entre les points import java lang Math class Point private double x private double y Point double x double y this x x this y y public double getX return x public double getY return y C public double distance Point p double px this getX - p getX double py this getY - p getY return Math sqrt px px py py public class Test public static void main String args Point p new Point Point p new Point System out println P p getX p getY System out println P p getX p getY System out println La distance entre P et P est p distance p Exercice Héritage ?? Créez une classe Person ? ?? Créez une classe Student ? et une autre classe Teacher ? les deux héritent de la classe Person ? ?? La classe Student ? aura une méthode publique GoToClasses ? qui a ?chera à l ? écran I ? m going to class ? ?? La classe Teacher ? aura une méthode publique Explain ? qui a ?chera à l ? écran Explanation begins ? En plus il aura un attribut privé subject ? de type string C ?? La classe Person ? doit
Documents similaires
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/11702276251s93mjqmk6suwcij54cgygaghmbjmpsorcsydov0dj85xn3yqzxea7r9tyrf16u5ols6m3ngqcjrbmzgprmmhjb4pidkk2vmnroye.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/0q3QYG19nN8eFU0OgAqvJ8EGlpz3ohJqiRfXsmii60HWepUbihyCIBm79lFRsVvIMpRMqtT9zkjdUjOQPwUrij1V.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/75gM8Lwpcc1zGXSKHSUXJy3KKlXiwwAe7p04cxN2eCVZQdfaA394PlRSsG2h6Ghvb7npa60oVB5dnjBe4sN5Ql0t.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/11702803079qgavbzco0rtlnmxmu4e11saknglvpeskv3qm8mzg7dpvvzjcmxjjhnxepitt7owowmktjetmuu1b6dp7tbbtwoglf1adj6shzkog.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/117023150583z1geaoy7zwjef6rdfi9so5m7sob3egipimvs1fojekfymsethr2vqoxseawhkv5njqpyr9wah4zzt6n7jbuqjz81u5tgxfd49cw.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/nTRvtPJjj0MJfLXgIxtsLCuFrYKWyQvA3sBkZVZpuQ6Y3vVc9FIJglDyJjOutCyfadi0YYFMG2gneIEJQGdlQsbi.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/BVa4fDdikoM7UzYsoPdgFwg1JTKgu9kIPPjpJY8fzTCBycrUchMmRfhu1It6OwLGyJuYiud5VaSWKYRk3ZuHioEC.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/O4zqeG70JL8pqOZRmDjib1snKlnz9YdVHJ289HPQzwBnSzVktYRLYwVm5qyzUoXCA2wa1YQrIH4MNSO8wU5qdKAl.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/tOONoveNGS3SeiTQlngEFP9TJlZokyM2cI85FPGD3MiVfQglMNJCw244FPSi7hL1nZTHrA8fZXwaiCag299n5xaQ.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/11702755828bku6jvcq9tnkt3xkd5w007m3ovhah4x02zkynwvg6k0b73hpezxkyfqmgjfzizqklmdnx0mhpeaow94w4oph9zi6jxdojhg1qoip.png)
-
32
-
0
-
0
Licence et utilisation
Gratuit pour un usage personnel Aucune attribution requise- Détails
- Publié le Aoû 17, 2022
- Catégorie Heavy Engineering/...
- Langue French
- Taille du fichier 44.7kB