473,406 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

method in read from file

Hi all;

I have some difficalty to write some method in read from file.I write a method of reading from file that contains grades obtained by students in 4 different courses.and this method reads these values and prints the minimum, maximum and average of grades for each student. It should also print the same for all the students. I write the method of printing avarage and also i try to write min and max method but when I compile there no min and max grade . can you explan to me what should i do.
i put this code of finding min and max in readFromFile method

for(int i=1;i<arr.length;i++)
{
if ( arr[i] > max ) max = arr[i];
}
System.out.println( max);
}
for(int i=1;i<arr.length;i++)
{
if ( arr[i] < min ) min = arr[i];

System.out.println(min);

}
Apr 7 '08 #1
1 1118
pronerd
392 Expert 256MB
If you are new to using forums you may want to review the posting tips. It will help you get better responses. For starters when posting code please use code tags. Just posting code as text makes it very hard to read. Also just saying it does not work does not provide much to go on. What happens? Is there a run time error, does it not compile, does it print out nulls, or just print out blank spaces, etc.

Have you verified that there are actually values in the array? You may want to add a temporary test line as I have shown below to verify values are being passed. Also it also looks like your braces may not match up. There are three closing braces in the code shown, but only two opening braces. Java compilers allow you to do if tests with out using braces, but it is a bad habit to get into. I can cause a lot of confusion.


Expand|Select|Wrap|Line Numbers
  1.  
  2.     for(int i=1;i<arr.length;i++) {
  3. System.out.println( "Array value found :  "+arr[i] );
  4.     if ( arr[i] > max ) {
  5.             max = arr[i];
  6.         }
  7.      }
  8.  
  9.      System.out.println( max);
  10.  
  11.     for(int i=1;i<arr.length;i++) {
  12.         if ( arr[i] < min ) {
  13.             min = arr[i];
  14.         }  
  15.     }    
  16.  
  17.     System.out.println(min);
  18.  
  19.  
Apr 7 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Trevor Fairchild | last post by:
Hello, all. I am writing a program that parses an html report (generated by another program). I use the Open "C:\...." for Input As myValue method to open the html, and read through it...
15
by: Thomas Scheiderich | last post by:
I am trying to understand Session variables and ran into a question on how they work with data that is passed. I have an HTM file that calls an ASP file and sends the name either by GET or POST....
2
by: Bob Rock | last post by:
I already found an alternative way to accomplish this (using ReadBytes), still I'd like to understand why I'm getting and error reading a text file using the following method. The exception is...
14
by: J.S. | last post by:
In a Windows Form application, which is the better method to concatenate large blocks of code? 1. Reading the text from text files. 2. Adding the text to the VB file itself? Thanks! J.S. ...
5
by: Avi Kak | last post by:
Hello: Does Python support a peek like method for its file objects? I'd like to be able to look at the next byte in a disk file before deciding whether I should read it with, say, the read()...
23
by: ShaneO | last post by:
Hello, I wish to extract embedded string data from a file using a Binary Read method. The following code sample is used in VB.NET and similar code is used in VB6 - (Assume variable...
2
by: slizorn | last post by:
hi guys, i need to make a tree traversal algorithm that would help me search the tree.. creating a method to search a tree to find the position of node and to return its pointer value basically i...
1
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
The description of the XMLDocument.Load method doesn't quite answer the question. When passing in a FileStream object to the Load method, does it load the entire document into memory? For...
2
by: Steven D'Aprano | last post by:
I understood that HTTPError objects always have a read method, so they can be treated as if they were a webpage. E.g. something like this simplified snippet: address =...
4
by: lilyumestar | last post by:
I have project I have to do for class. We have to write 4 different .java files. Project2.java HouseGUI.java House.java HouseSorting.java I already finish House.java and I need to work on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.