-
December 18th, 2012, 01:44 PM
#16
Re: i need help writing a program using array. ASAP!
okY so i got the errors down to 5.. here the new code so far... i forgot to give a option for the user to enter grade..
import java.util.Scanner;
public class Q7_A_112532 {
public static void main(System[] args){
Scanner input = new Scanner(System.in);
int num = 0;
int excellentstudent;
excellentstudent = 0;
double percentage = 0;
int grade;
System.out.print("enter the total number of students: ");
num = input.nextInt();
int i;
int studentarray;
studentarray = new.int[num];
{for (i = 0; i < studentarray.length, i++ )};
sum = sum + arr[num];
System.out.print("Enter the grade of the student: ");
grade = input.nextInt();
if (grade >= 90 )
gradecount ++;
percentage = count * 100 / num;
System.out.printf("The percentage f excellent student is : %.1f", + percentage);
}
}
-
December 18th, 2012, 02:00 PM
#17
Re: i need help writing a program using array. ASAP!
um i thought u would need to calculate the percentage of excellent students... thats why... u think i should remove that part?
But you aren't using it anywhere. But I wouldn't worry about that at the moment, the first thing is to get your code compiling.
-
December 18th, 2012, 02:04 PM
#18
Re: i need help writing a program using array. ASAP!
Please use code tags when posting code.
Format your code properly so the curly braces and indents are all consistently aligned, this will help highlight at least one problem.
If I have to keep asking you to post error message etc this will take all night and I don't have all night. If there are 5 errors, post the messages.
-
December 18th, 2012, 02:10 PM
#19
Re: i need help writing a program using array. ASAP!
okay i got all the errors i could fixed... but still have four left!
C:\Users\Al Doctor\Documents\NetBeansProjects\HafsaShahab_112532\src\Q7_A_112532.java:25: error: <identifier> expected
studentarray = new.int[num];
C:\Users\Al Doctor\Documents\NetBeansProjects\HafsaShahab_112532\src\Q7_A_112532.java:25: error: <identifier> expected
studentarray = new.int[num];
C:\Users\Al Doctor\Documents\NetBeansProjects\HafsaShahab_112532\src\Q7_A_112532.java:26: error: illegal start of expression
{for (i = 0; i < studentarray.length; i++ )};
C:\Users\Al Doctor\Documents\NetBeansProjects\HafsaShahab_112532\src\Q7_A_112532.java:42: error: reached end of file while parsing
}
4 errors
i am so sorry for bothering you.... but at the current moment u are the only help i have!
-
December 18th, 2012, 03:13 PM
#20
Re: i need help writing a program using array. ASAP!
i am so sorry for bothering you..
Don't worry, I'm just concerned we don't have enough time.
The first two errors I have already explained in an earlier post.
The 3rd error is because the for statement shouldn't be wrapped in curly braces
The 4th is because you probably don't have the same number of opening and closing curly braces hence my earlier comment about formatting your code properly.
Last edited by keang; December 18th, 2012 at 03:32 PM.
-
December 18th, 2012, 03:48 PM
#21
Re: i need help writing a program using array. ASAP!
i think the atempt of fixing the last four errors i have messed it all up all over...i bet u might be thinking i am like a crazy person or something.... but i think its slowly getting over m,y head.... now i think i am screwed it big time... coz in the middle i was working on another program... which was fine... but now donno what to do!
am, trying to get back to where it was..
-
December 18th, 2012, 04:05 PM
#22
Re: i need help writing a program using array. ASAP!
okay wait i think i got everything back.. lemme work on ur suggestion and i will get back to you
-
December 18th, 2012, 04:17 PM
#23
Re: i need help writing a program using array. ASAP!
Fixing one error can often make more errors appear, it doesn't necessarily mean you done something wrong.
-
December 18th, 2012, 04:20 PM
#24
Re: i need help writing a program using array. ASAP!
yeah never thought of that..am gonna keep that in mind... okay so am down to 3 errors..
-
December 18th, 2012, 04:23 PM
#25
Re: i need help writing a program using array. ASAP!
okay so i removed the curly brace from one of em... but there is a new error in it..
C:\Users\Al Doctor\Documents\NetBeansProjects\HafsaShahab_112532\src\Q7_A_112532.java:26: error: <identifier> expected
studentarray = new.int[num];
C:\Users\Al Doctor\Documents\NetBeansProjects\HafsaShahab_112532\src\Q7_A_112532.java:26: error: <identifier> expected
studentarray = new.int[num];
C:\Users\Al Doctor\Documents\NetBeansProjects\HafsaShahab_112532\src\Q7_A_112532.java:48: error: class, interface, or enum expected
}
3 errors
-
December 18th, 2012, 04:31 PM
#26
Re: i need help writing a program using array. ASAP!
okay so got ride of the last error... but the other two are still pending... can re-explain what i have to do to fix it.
-
December 18th, 2012, 04:45 PM
#27
Re: i need help writing a program using array. ASAP!
Without seeing the current code it's hard to say exactly but you certainly shouldn't have a '.' in 'new.int' and you probably haven't declared studentarray
-
December 18th, 2012, 04:53 PM
#28
Re: i need help writing a program using array. ASAP!
import java.util.Scanner;
public class Q5_112532 {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int integer;
System.out.print("Enter an integer less then 2147483648: ");
integer = input.nextInt();
int sum = 0;
while (integer != 0){
sum += integer % 10;
integer /= 10;
}
System.out.print("the sum of digits of integers is ");
if (sum % 2 == 0){
System.out.println("even!");
}
else
{
System.out.println("odd!");
}
}
}
SO THIS WHAT I HAVE GOTTEN AFTER ALL THAT!!
-
December 18th, 2012, 04:55 PM
#29
Re: i need help writing a program using array. ASAP!
WOOPS DORRY WRONG PROGRAM!!
import java.util.Scanner;
public class Q7_A_112532 {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int num = 0;
double percentage = 0;
int grade;
System.out.print("Enter the number of students");
num = input.nextInt();
int sum;
int studentarray;
studentarray = new.int[num];
for (num = o; num < studentarray.length; num ++);
sum = sum + arr[num];
System.out.print("enter the grade of the student: ");
grade = input.nextInt();
if ( grade >= 90)
gradecount ++;
percentage = gradecount * 100 / num;
System.out.printf("The percentage of excelent students: %.1f", +percentage);
}
}
-
December 18th, 2012, 05:07 PM
#30
Re: i need help writing a program using array. ASAP!
What about error messages and you still have a '.' in 'new.int'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|