• Aucun résultat trouvé

Ce programme affiche la surface d’un cercle dont * l’utilisateur entre le rayon

N/A
N/A
Protected

Academic year: 2022

Partager "Ce programme affiche la surface d’un cercle dont * l’utilisateur entre le rayon"

Copied!
1
0
0

Texte intégral

(1)

Fichier CercleMain.java

import java.util.Scanner;

/**

* Classe representant un cercle

**/

class Cercle {

// champs : rayon du cercle double r;

// Constructeur : initialisation des champs Cercle(double nouvRayon) {

r = nouvRayon;

}

// methode de calcul d’une surface double calculeSurface() {

return(3.1416*r*r);

}

}// Fin de class Cercle

/**

* Ce programme affiche la surface d’un cercle dont

* l’utilisateur entre le rayon

**/

public class CercleMain {

// methode main() : point d’entree du programme public static void main(String[] args) {

// pour les entrees de donnees au clavier

Scanner entreeClavier = new Scanner(System.in);

// capture d’un double au clavier

double rayon = entreeClavier.nextDouble();

// creation d’un objet de type Cercle Cercle monCercle = new Cercle(rayon);

// calcul de sa surface

surface = monCercle.calculeSurface();

// affichage du resultat

System.out.println("Voici la surface du cercle de rayon " + monCercle.r + " : " + surface);

} }

1

Références

Documents relatifs

public static void main(String[] args) throws IOException { InputStream in=new FileInputStream(args[0]);.. Et avec

public static void main(String[] args) throws Exception { NotePad notes = new NotePad();. Invoker invoke = new

public static void main(String [] args) throws IOException{. ServerSocket serveur =

public static void main(String [] args) throws IOException{. ServerSocket serveur =

public static void main (String[] args) throws IOException {. int port; // no de port

public static void main(String[] args) { String chaineEntree = "z";. BufferedReader in =

public static void main(String [] args) { launch(args);}. } public class

 Pour l'exemple, le nom du fichier doit être : Main.java... Exécution d’un