Results 1 to 3 of 3
Thread: difficulty
- 03-04-2009, 12:34 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 5
- Rep Power
- 0
difficulty
hey guys. I created this code and it's really messy.
/**
* enterstudentdetails
*/
import java.util.*;
public class function1
{
int X;
int function;
String desiredChoice= "Unknown";
public function1() {
Scanner keyboard= new Scanner(System.in);
if(function==1){
String[] marks;
marks=new String[3];
marks[1]="Maths";
marks[2]="Physics";
marks[3]="Computing";
int MAX_NO_OF_STUD=1000;
int N;
String name;
int studNo;
System.out.print("Type the number of students you want to input");
studNo=keyboard.nextInt();
marks=new int[studNo];
for(N=1;N<=studNo;N++){
grade(N);
System.out.println("Enter name for student number" +N+ ":" );
name=keyboard.nextInt();
System.out.println("Enter form /1-5/ for student " +N+ "." +name+ ":" );
form=keyboard.nextDouble();
System.out.println("Enter group /A-D/ for student " +N+ "." +name+ ":");
group=keyboard.nextChar();
System.out.println("Enter mark for maths for student" +N+ "." +name+ ":" );
mark[1]=keyboard.nextDouble();
System.out.println("Enter mark for physics for student" +N+ "." +name+ ":" );
mark[2]=keyboard.nextDouble();
System.out.println("Enter mark for computing for student" +N+ "." +name+ ":");
}
}
After data is input, I need to find the highest mark for each subject (maths,physics and computing) in each individual group(A,B,C,D). I have really struggled a lot and yet can't see how to go about it. How can I link them so dat the marks correspond to each Form and Group :confused::confused:
- 03-04-2009, 04:55 PM #2
Member
- Join Date
- Feb 2009
- Posts
- 9
- Rep Power
- 0
You have all the code in the constructor. Make a new class with the main method and add all the grades from there. Plus you already initialized the marks array as type String, and you can't change it to type int. I advise you to make 3 arrays, 1 for each subject, then add the marks accordingly. Then loop through the array searching for the highest mark.
- 03-04-2009, 05:36 PM #3
Member
- Join Date
- Mar 2009
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Tomcat & JBoss [for jsp] are of equal difficulty to setup & run (localhost_lastest ed
By lse123 in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 01-03-2009, 10:00 AM -
Difficulty in finding the right algorithm
By SolidCobra in forum New To JavaReplies: 3Last Post: 10-05-2008, 11:55 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks