0% found this document useful (0 votes)
25 views2 pages

Code Java

The document contains code for two Java classes that take user input of numbers and coefficients. Class2 takes input of notes, coefficients, and subject names to calculate total, average, and display results. Class1 takes coefficient input to calculate sum, minimum, maximum, and average. Both classes use Scanner and arrays to store input and perform calculations in for loops before outputting results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

Code Java

The document contains code for two Java classes that take user input of numbers and coefficients. Class2 takes input of notes, coefficients, and subject names to calculate total, average, and display results. Class1 takes coefficient input to calculate sum, minimum, maximum, and average. Both classes use Scanner and arrays to store input and perform calculations in for loops before outputting results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

package pack1;

importjava.util.Scanner;

publicclass Class2 {

/**
* @paramargs
*/
publicstaticvoid main(String[] args) {
// TODO Auto-generated method stub
Scanner clavier = newScanner(System.in);

System.out.println("entrer le nombre de note : ");


int n = clavier.nextInt();
doublenote[] = newdouble[n];
intcoef [] = newint[n];
String libelle[] = new String[n];

intsomNoteCoef = 0;
doublesomeNote = 0;
intsomCoef = 0;

// some = segma note * cof i

// s += cof i * note i
//x+=coef i

for (int i = 0; i <coef.length; i++) {


System.out.println("entrer le nom de matiere N "+(i+1));
libelle[i] = clavier.next();

System.out.println("entrer la note de "+libelle[i]);


note[i] = clavier.nextInt();

System.out.println("entrer le coef de "+libelle[i]);


coef[i] = clavier.nextInt();
somNoteCoef = (int) (note[i]*coef[i]);
someNote +=somNoteCoef;
somCoef+= coef[i];
}

for (int i = 0; i <libelle.length; i++) {


System.out.println("matier : "+libelle[i]+" || Note :
"+note[i]+" || Coef : "+coef[i]);
}

System.out.println("Somme total= "+someNote);


System.out.println("Moyen= "+(someNote/somCoef));

package pack1;

import java.util.Scanner;
publicclass Class1 {

/**
* @param args
*/
publicstaticvoid main(String[] args) {
// TODO Auto-generated method stub
Scanner clavier = new Scanner(System.in);

System.out.println("entrer le nombre de coef : ");


int n = clavier.nextInt();
intcoef[] = newint[n];

intsom = 0;

double moy = 0;
for (int i = 0; i < coef.length; i++) {
System.out.println("entrer le coef N "+(i+1));
coef[i] = clavier.nextInt();

}
int max = coef[0];
int min = coef[0];

for (int i = 0; i < coef.length; i++) {

som += coef[i];

if (max < coef[i]) {


max = coef[i];
}

if (min > coef[i]) {


min = coef[i];
}
}

System.out.println("la somme de coef = "+ som);


System.out.println("le Max = "+ max);
System.out.println("Le Min = "+ min);
moy = ((som*100/n));

System.out.println("la Moyenne = "+moy/100);

You might also like