Results 1 to 8 of 8
  1. #1
    delbg is offline Member
    Join Date
    Jan 2009
    Posts
    3
    Rep Power
    0

    Default Kindly assist me...

    1.capture scores of three students in three subjects maths, eng,science
    calculate each student's average score and rank them according to their averages and output these rankings.
    allow user to enter scores.

    2. Array implementation
    Given the following marks scored in a programming test and that the pass mark is the average of all the marks, write a program to list those students who have passed.E.g:marks in %
    Fred – 21, Ann – 52, Robert – 71, Cecile – 33, Jennifer – 41, George – 56, Mary – 89, Alfred – 71, Mike – 54 and Pauline – 48.

    3. The Meteorological Department receives weather data from 5 different weather stations around the country. The data recorded includes the speed (on a scale from 0 to 100), and direction (in degrees from 0 to 360) of the Wind, together with the air temperature (in degrees C), and humidity (on a scale from 0 to 100). This data is measured every four hours at each station. At the end of each day, each Station sends the above data, together with the day’s total rainfall recorded at the station, to the Headquarters. The Department then processes the data to obtain certain information for weather forecasts.
    Write a program that calculates the average daily Rainfall for all the stations and the average daily Temperature for each of the stations. Define and declare any other variables you will need.

  2. #2
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    what don't you understand about it?
    USE CODE TAGS--> [CODE]...[/CODE]
    Get NotePad++ (free)

  3. #3
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    This forum is intended to answer specific questions about how the Java language works or why a particular piece of code is not acting as expected.

    We do not provide code, especially not when based on user requirements or homework assignments.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Credits to Steve and angryboy. This is a forum delbg, not a place where your home can be done from others. You must put some effort to do this first of all. Then ask your questions more clearly with the effort you made.

  5. #5
    delbg is offline Member
    Join Date
    Jan 2009
    Posts
    3
    Rep Power
    0

    Default Again

    Well, thank you...I appreciate your concern.
    I've struggled with this but it is giving me errors about operators, incompatible types and the coursename.Would you please tell me where I am going wrong?


    import java.awt.*;
    import javax.swing.*;

    public class Arrays
    {
    private String courseName;
    private int score;

    public Arrays(String name, int marks)
    {
    courseName=name;
    score=marks;

    }
    public void setCourseName(String name)
    {
    courseName=name;
    }
    public String getCourseName()
    {
    return courseName;
    }
    public static void main (String[] args)
    {


    double sum, average;
    sum = 0;

    System.out.println ("Everybody's score:");

    for(int i = 0; i < 4; i+=1)
    {
    System.out.print ("Course Name: ");

    courseName=name;

    for(int j = 0; j < 4; j+=1)
    {
    System.out.print("Subject score: ");


    sum = sum + marks[j];
    }

    average = sum / 3;
    System.out.println (name[i] + "'s Average: " + average);
    System.out.println ();
    sum = 0;
    }


    }
    }

  6. #6
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    First, don't call your class Arrays. Java has a core class called Arrays; you may not get an error, but masking off core classes is a bad idea. Use MyArrays, or better, RainFall.

    Here is what your main() should look like:
    Java Code:
    public static void main(String[] args) {
      MyArrays instance = new MyArrays();
      instance.run();
    }
    ...
    public void run() {
      // The top-level logic of your program
    }
    I named the method run() because it has to have some name, and run() allows your class to be used on a thread with no modification. You can call it something else, like topLevelLogic() if you want.

    Move everything out the main() method. You can't access your instance fields from a static method. That is the beginning of your problem.

    Next, take a *blank sheet of paper* and write out, in plain words, what your program should do, step by step. Use indentation to help you see the structure of control blocks for conditions (if) and loops (while). Use several pieces of a paper, if necessary, until you can read through what you have written and have it make sense.

    Then write some code, compile it, and fix one error at a time, recompile, and so on. When you hit an error you don't understand, then post some more code *and* the error message.

    I'm not being mean. I turn to pencil and paper when I hit some tough logic, and *everyone* debugs the same way.
    Last edited by Steve11235; 02-02-2009 at 03:18 PM. Reason: fix an oops...

  7. #7
    delbg is offline Member
    Join Date
    Jan 2009
    Posts
    3
    Rep Power
    0

    Default Arrays

    Thank you for the help, I am giving it a try step by step...will get back to you
    Last edited by delbg; 02-04-2009 at 05:35 PM. Reason: spelling

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Yes delbg, the way you are looking to take is much better. Point is you should learn something new always from other members comments on your questions.

    Start work on step by step, seriously think about Steve's advice on his last post.

Similar Threads

  1. Content Assist
    By michael19 in forum Eclipse
    Replies: 3
    Last Post: 11-20-2008, 07:09 PM
  2. kindly answer the queston in attachment file
    By abhinav_jain09 in forum Advanced Java
    Replies: 11
    Last Post: 09-19-2008, 04:47 PM
  3. Kindly Help me to apply Stylesheet
    By AMATYA-CHANAKYA in forum Advanced Java
    Replies: 0
    Last Post: 03-18-2008, 06:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •