Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Programming beginner

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Thanked 0 Times in 0 Posts

    Default Programming beginner

    Hello everyone!! I am in my second year of college and am majoring in computer science, however, my computer programming beginner class is the first programming I have ever done in my life and I would love if anybody could comment on this homework assignment I have! I've done most of it but there are still pieces missing. Here are the instructions:
    Write a program: MidtermStat.java, to output (on screen) the average, lowest, and highest grades in the midterm exam (if there is multiple highest and lowest, just output one of them). The midterm grades are previously stored in a text file named "midterm_grade.txt". You may assume there are exactly 30 grades in the file.
          import java.io.*;
          import java.util.*;	
          public class MidtermStat {
    	public static void main(String[] ags) throws IOexception {
    	       Scanner in = new Scanner(new FileReader("midterm_grade.txt"));
    	       int number;
    	       int lowest = 36.0;
    	       int highest = 100.0;
    	       double average;
    	        System.out.println("Numbers on file midterm_grade.txt: ");
    	          while (in.hasNextInt())    
    	           number = in.nextInt();
    	           System.out.println("The lowest grade is: ");
    	           System.out.print("The highest grade is: ");

    //I'm supposed to be using count-controlled loop or event controlled loop in this
    //along with if-else statements
    //the file called "midterm_grade.txt" is a seperate file composed of approximately 30 grades
    //the lowest grade is 36.0 and the highest is obviously 100.0

  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Thanked 619 Times in 561 Posts
    Blog Entries

    Default Re: Programming beginner

    Aside from finishing the program, there are 2 things you could do to improve your code:

    1. Format it to be easy to read. Here's the standard coding convention for Java (It probably won't affect the performance of your code, but it will make it easier for others to read)
    2. Comment your code. More importantly, strive for high-quality comments rather than large quantities of comments.

    Good luck on finishing your program

  3. #3
    Junior Member
    Join Date
    Oct 2010
    Thanked 0 Times in 0 Posts

    Default Re: Programming beginner

    Thank you for the link and the help!

Similar Threads

  1. Java Beginner Here!
    By j3nn42o in forum The Cafe
    Replies: 10
    Last Post: January 10th, 2011, 04:57 AM
  2. Beginner - Help with my code.
    By eddross in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 12th, 2010, 09:30 AM
  3. Basic Beginner Help
    By SRD in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 11th, 2010, 04:27 PM
  4. Java Beginner
    By rannoune in forum Java Theory & Questions
    Replies: 3
    Last Post: December 25th, 2009, 03:30 AM
  5. I need a help ! i am beginner
    By yinky in forum Java Theory & Questions
    Replies: 3
    Last Post: September 30th, 2009, 07:22 AM