Java:j' ai une erreur dans mon prg
domxaline
-
irmeche Messages postés 76 Statut Membre -
irmeche Messages postés 76 Statut Membre -
Bonjour,
voilà j'écris ce prg mais j'ai 2 erreur dans la main,quelqu'un peut m'aider le corriger
eclipse m'indique erreur dans la ligne
inputStreamReader cannot be resolved to a type
sm cannot be resolved or is not a field
aidez moi svp pour ce prg
voilà j'écris ce prg mais j'ai 2 erreur dans la main,quelqu'un peut m'aider le corriger
import java.io.*;
public class StudentMarks
{
int r1=0,r2=0,r3=0,r4=0,rn=1;
static BufferedReader br;
public StudentMarks( int num)
{
int arr[]= new int [num];
try
{
for(int i=0; i<arr.length;i++)
{
System.out.println("enter the marks for roll nb"+rn);
arr[i]=Integer.parseInt(br.readLine());
rn++;
}
for(int j=0; j<arr.length;j++)
{
if (arr[j]>=0&& arr[j]<=40)
{
r1++;
}
else if (arr[j]>40 && arr[j]<=60)
{
r2++;
}
else if (arr[j]>60 && arr[j]<=80)
{
r3++;
}
else if (arr[j]>80 && arr [j]<=100)
{
r4++;
}
}
System.out.println("Students securing marks in the range of 0-40 are \t"+r1);
System.out.println("Students securing marks in the range of 40-60 are \t"+r2);
System.out.println("Students securing marks in the range of 60-80 are \t"+r3);
System.out.println("Students securing marks in the range of 80-100 are \t"+r4);
}
//end of try
catch(Exception exp)
{
System.out.println(exp);
}
//end catch
}
//end constructor
public static void main (String args[])
{
int sm;
try
{
br=new BufferedReader(new inputStreamReader(System.in));
System.out.println("Enter the total nb of students in the class");
int total_students=Integer.parseInt(br.readLine());
StudentMarks.sm=new StudentMarks(total_students);
}
//end of try
catch(Exception exp)
{
System.out.println(exp.getMessage());
}//end of catch
}//end main
}//end of class
}
eclipse m'indique erreur dans la ligne
br=new BufferedReader(new inputStreamReader(System.in));
inputStreamReader cannot be resolved to a type
sm cannot be resolved or is not a field
aidez moi svp pour ce prg
A voir également:
- Java:j' ai une erreur dans mon prg
- Jeux java itel - Télécharger - Jeux vidéo
- Waptrick java football - Télécharger - Jeux vidéo
- Waptrick java voiture - Télécharger - Jeux vidéo
- Java apk - Télécharger - Langages
- Eclipse java - Télécharger - Langages
1 réponse
essaye comme ca :
import java.io.*;
public class StudentMarks {
int r1 = 0, r2 = 0, r3 = 0, r4 = 0, rn = 1;
static BufferedReader br;
public StudentMarks(int num) {
int arr[] = new int[num];
try {
for (int i = 0; i < arr.length; i++) {
System.out.println("enter the marks for roll nb" + rn);
arr[i] = Integer.parseInt(br.readLine());
rn++;
}
for (int j = 0; j < arr.length; j++) {
if (arr[j] >= 0 && arr[j] <= 40) {
r1++;
} else if (arr[j] > 40 && arr[j] <= 60) {
r2++;
} else if (arr[j] > 60 && arr[j] <= 80) {
r3++;
} else if (arr[j] > 80 && arr[j] <= 100) {
r4++;
}
}
System.out.println("Students securing marks in the range of 0-40 are \t"+ r1);
System.out.println("Students securing marks in the range of 40-60 are \t"+ r2);
System.out.println("Students securing marks in the range of 60-80 are \t"+ r3);
System.out.println("Students securing marks in the range of 80-100 are \t"+ r4);
}
// end of try
catch (Exception exp) {
System.out.println(exp);
}
// end catch
}
// end constructor
public static void main(String args[]) {
try {
br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the total nb of students in the class");
int total_students = Integer.parseInt(br.readLine());
StudentMarks sm = new StudentMarks(total_students);
}
// end of try
catch (Exception exp) {
System.out.println(exp.getMessage());
}// end of catch
}// end main
}// end of class