Please Help with a simple java assignment, stuck! - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Please Help with a simple java assignment, stuck!

ryou00730ryou00730 Posts: 1Member
Hello,
I'm trying to do my java assignment but I got stuck on a loop. I'm really new to all of this, so it's almost impossible for me. I'm trying to define the class that will take care of reading in different categories (ie assignment, lab assignment, final, midterm) plus their grade in double type from a file, and will update the current subtotal of that category in a certain weight of the class. I have this so far, and I am stuck at the while loop at the bottom where i need to [b]"Write a loop to ask the scanner object to read in each category-mark pair. In the loop, for each read-in pair, update the corresponding sub-total variables."[/b] Any help would be greatly appreciated!

import java.io.*;
import java.util.*;
public class MarkManager
{
private PrintWriter writer;

public MarkManager()
{
try {
writer = new PrintWriter(new BufferedWriter(new FileWriter("cs1073marks", true)));
} catch(IOException e) {System.err.println("Cannot open output file: cs1073marks"); System.exit(1);}
}

public void saveMark(String category, double mark)
{
writer.write(category + " " + mark + "
");
}

public void close()
{
writer.close();
}

public double getTotalScore()
{
Scanner scanner;
try {
scanner = new Scanner(new File("cs1073marks"));
} catch(IOException e) {System.err.println("Cannot open input file: cs1073marks"); System.exit(2);}
double Lab = 0;
double Assignment = 0;
double Midterm = 0;
double Final = 0;

while (scanner.hasNext())
{

}



}
}

Comments

Sign In or Register to comment.