> Java > tutorials > javanotes > Start-Forum
> Java > tutorials > javanotes > Start-Forum
by ZweiBieren How to start writing a Java program Java coffee cup logo
 
Thread: Marks programm

Hi, I have to program a markssaver:

which is able to

  1. I give it some marks
  2. It saves these marks
  3. It saves the number of students
  4. It gives me back the marks + the students+ the average

Does someone knows about such a program code for me (java)?
Can i download it somewhere?

My first response was not really helpful. The query was from a student trying to satisfy a class assignment. I just said:

I googled "class grades" and got a bunch of choices.
Rule 12: Never program for yourself what others have already done.

Many teachers get by with just a spreadsheet.

Later I responded in general terms with some wisdom gained from writing/rewiting many programs:.

Here's some notes that may help. The important design step is to focus on interfaces:

  • How does the program get the data from the user?
    Prompt for a line where each line has name and grade
    OR prompt separately for each name and each grade?
  • How is the data stored in a file? Typically each line in the file has a name and grade separated by a special character like a colon.
  • What is the in-memory representation of the data? Possibly a new class called GrayList which extends ArrayList and contains Grade objects where each has a name and grade.
  • What is the format of the output?

Now write GrayList methods to

  • read into a GrayList list from the console,
  • write a GrayList to a file,
  • read a file into a GrayList,
  • and compute the average from a GrayList.

The final program more or less just calls these methods.


A Framework for building components

Some recent posts have had problems organizing the outline of a program. To add yet another option, I'll include below the sort of framework I use for building JComponents. Each source file has its own main() method and an enclosed class called TestFrame. The main method creates an instance of the JComponent and then an instance of TestFrame displaying that JComponent. Finally it starts the ball rolling by calling the TestFrame's setVisibility() method.

SamplePanel.java

 

 
Copyright © 2018 ZweiBieren, All rights reserved. Jun 28, 2018 20:52 GMT Page maintained by ZweiBieren