The Artima Developer Community
Sponsored Link

Java Answers Forum
About Multidimensional Arrays

3 replies on 1 page. Most recent reply: Apr 27, 2002 11:24 AM by Jeannie Kwa

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Jeannie Kwa

Posts: 4
Nickname: kaw
Registered: Apr, 2002

About Multidimensional Arrays Posted: Apr 25, 2002 11:30 AM
Reply to this message Reply
Advertisement
I'm sorry to bother you with this qn .I came across with this tough exercise ,which I not able to
figure how to work out. If I want to design an interface which will perform the following functions:
Create a record contains 15 students.

1) We are free invited to enter the details of a Student with the name,
and enter the 3 Marks obtained in each 3 subjects.(like..Integer.parseInt(input);read their input

2) Calculate the average test score of each student.

3) Display the name of the student and test score according to their grade :DesTination, Credit, Pass
or Failed.
Fail=less than 40
Pass=less than 60 more than 40
Credit=Less than 70 more than 60
Destination=More than 70

4) Calculate and display the highest and lowest average score.

5) Develop in Application.

Appreciate your patience on this matter. I look forward to your reply.

Sincerly

Jeannie


Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: About Multidimensional Arrays Posted: Apr 26, 2002 4:19 AM
Reply to this message Reply
Jeannie,
What is the question exactly... ?
Could you be more specific ?
Thomas,

Jeannie Kwa

Posts: 4
Nickname: kaw
Registered: Apr, 2002

Re: About Multidimensional Arrays Posted: Apr 26, 2002 9:51 AM
Reply to this message Reply
Hello Tsmets,

I dont know what's the first step i shd work out. I tried to do it. But that's not what i want from the output in the interface.

// SumIntArgs.java

class SumIntArgs
{
public static void main (String [] args)
{
int sum = 0;

for (int i = 0; i < args.length; i++)
sum += Integer.parseInt (args );

System.out.println ("Sum = " + sum);
}
}

interface StudentFunctions
{
double averageTestScore ();
// Other methods
}

Even so, I'm not sure what's the step that i need to follow. That's my qn. How can i get the output which i want? Can u show me how to work this interfact on the qn?
Thks for ur replying

Jeannie Kwa

Posts: 4
Nickname: kaw
Registered: Apr, 2002

Re: About Multidimensional Arrays Posted: Apr 27, 2002 11:24 AM
Reply to this message Reply
Thomas,

I tried to work out on this qn. However there are some errors on it.
Pls help me on it.
And how and where can i make the function to calcuate on their grading and <u>average score</u>. Below is the source code for this program on Applet. Appreciate all the assistance on this program.

import java.awt.*;
import java.awt.event.*;
import java.io.*;


public class Smark extends Frame implements ActionListener {

Label lblTitle,lblSname,lblMark1,lblMark2,lblMark3;
TextField txtSname,txtMark1,txtMark2,txtMark3;
Button btnReset,btnExit,btnPrint;
TextArea sta;

public Smark() {
setSize(500,550);
setLayout(null);
setLocation(null);
setTextArea int (10,30);

lblTitle = new Label("RESULT CALCULATOR");
lblTitle.setLocation(200,30);
lblTitle.setSize(150,30);
add(lblTitle);


lblSname = new Label("Enter Name : ") ;
lblSname.setLocation(150,40);
lblSname.setSize(120,30);
add(lblSname);

txtSname = new TextField("",10);
txtSname.setLocation(150,40);
txtSname.setSize(120,50);
add(txtSname);

lblMark1 = new Label("Enter 1st Mark : ") ;
lblMark1.setLocation(200,50);
lblMark1.setSize(130,40);
add(lblMark1);

txtMark1 = new TextField("",10);
txtMark1 = new TextField("",10);
add(txtMark1);

lblMark2 = new Label("Enter 2nd Mark : ") ;
lblMark2.setLocation(200,50);
lblMark2.setSize(130,40);
add(lblMark2);

txtMark2 = new TextField("",10);
txtMark2 = new TextField("",10);
add(txtMark2);

lblMark3 = new Label("Enter 3rd Mark : ") ;
lblMark3.setLocation(200,50);
lblMark3.setSize(130,40);
add(lblMark2);

txtMark3 = new TextField("",10);
txtMark3 = new TextField("",10);
add(txtMark3);


btnPrint = new Button("PRINT");
btnPrint.addActionListener(this);
add(btnPrint);

btnReset = new Button("RESET");
btnReset.addActionListener(this);
add(btnReset);

btnExit = new Button("EXIT");
btnExit.setLocation(350,170);
btnExit.setSize(80,30);
btnExit.addActionListener(this);
add(btnExit);

sta=new TextArea ("",10,30);
setLocation();
setSize(500,550);
sta.setEditable(false);
add(sta);
}


public void actionPerformed(ActionEvent evt) {

if (evt.getSource() == btnPrint) {


} // end of btnPrint


if (evt.getSource() == btnReset) {


} // end of btnReset

if (evt.getSource() == btnExit) {
System.exit(0);
} // end of btnExit

} // end of actionPerformed



public static void main (String args[]) {
Smark fp = new Smark();
fs.show();
String Sname;
int mark1, mark2, mark3;
{
Student [] students =
double highestAvg = -1.0;
double lowestAvg = 101.0;

for (int i = 0; i < students.length; i++)
{
double avg = (students .mark1 + students .mark2 +
students .mark3) / 3.0;

if (avg > highestAvg)
highestAvg = avg;

if (avg < lowestAvg)
lowestAvg = avg;

System.out.print (students .name + " " +
students .mark1 + " " +
students .mark2 + " " +
students .mark3 + " " + avg + " ");

if (avg < 40)
System.out.println ("FAIL");
else
if (avg < 60)
System.out.println ("PASS");
else
if (avg < 70)
System.out.println ("CREDIT");
else
System.out.println ("DISTINCTION");
}

System.out.println ();

System.out.println ("Highest Average = " + highestAvg);
System.out.println ("Lowest Average = " + lowestAvg);
}
}

} // end of main

} // end of class

Flat View: This topic has 3 replies on 1 page
Topic: set up classpath to find packages Previous Topic   Next Topic Topic: Swing Applets

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use