Académique Documents
Professionnel Documents
Culture Documents
FSO – 2020
Exercice 2
class Point {
private double x, y, z;
public Point(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
public double calculer() {
return x+y+z;
}
}
public class Exercie2 {
public static void main(String[] args) {
Point A = new Point(5,2,3);
System.out.println("La somme est : " +
A.calculer());
}
Exercice 3
import java.util.Scanner;
class Etudiant {
private String nom, prenom, cne;
private double note1, note2, note3;
public Etudiant(String nom, String prenom) {
this.nom = nom;
this.prenom = prenom;
}
public Etudiant(String nom, String prenom, String cne) {
this(nom, prenom);
this.cne = cne;
}
public Etudiant(Etudiant A) {
this.nom = A.nom;
this.prenom = A.prenom;
this.cne = A.cne;
}
public Etudiant(String nom, String prenom, String cne,
double note1,double note2,double note3) {
this(nom, prenom,cne);
this.note1 = note1;
this.note2 = note2;
this.note3 = note3;
}
public void afficher() {
System.out.println("Nom: " + nom + ", prenom: " +
prenom + " et cne: "+ cne);
}
public double moyenne() {
return (note1+note2+note3)/3;
}
}
import java.util.Scanner;
public class Cercle {
private double rayon, x, y;
public Cercle(double x, double y, double rayon) {
this.x = x;
this.y = y;
this.rayon = rayon;
}
public void deplacer(double dx, double dy){
x += dx ;
y += dy ;
}
public void setRayon(double a){
rayon = a ;
}
public double getRayon(){
return rayon;
}
public void afficher() {
System.out.println("Un cercle de centre le point de
coordonnées "+ x + " et " + y + " et de rayon "+
rayon );
}
}
Exercice 5
import java.util.Scanner;
class Point {
private double x, y;
public Point(double x, double y){
this.x = x;
this.y = y;
}
public void afficher() {
System.out.println("Un point de coordonnées "+ x + "
et " + y);
}
}
class Cercle {
private double rayon;
private Point a;
public Cercle(double rayon, Point a) {
this.rayon = rayon;
this.a = a;
}
public void afficher() {
a.afficher();
System.out.println(" est le centre d'un cercle de
rayon "+ rayon );
}
}