Re: Java Help for a Beginner



Booter wrote:
I am working on a program that can takes numbers in as grades with a
delimiter of a ",". I have most of the code working but for some
reason I can never get out of the while loop in the code. If anyone
can help it would be greatly appreciated.

*****************CODE**************

import java.util.*;// need scanner

public class Grades
{
public static void main (String[] args)

Do not embed TAB characters in Usenet posts. Use spaces, a maximum of four per indent level.

People have to be able to read your code to help you with it.

{
Scanner classGrades = new Scanner(System.in);
Scanner delimiter = new Scanner(System.in);

This is probably your problem. You've declared two scanners for System.in and you don't seem ever to use the first one. Why do you need two? Why don't you use the first one?

System.out.print("Welcome to the Grade Calculator Program \n\n"
+ "Please enter the student scores as integers between 0 and
100.\n"

Those darn TAB characters!

+ "Separate the scores with a comma.\n"
+ "Follow the last student score with a negative number.\n"
+ "Enter the grades here: ");

//declairations [sic] for vars needed
int grade = 0;
int a = 0;

It is better in languages like Java to name a variable with a whole word that indicates its meaning in the logic of the problem. Readers have to ask, "What is an 'a'?" A better name would be "aCount" or "countOfA" or "numberOfAs".

int b = 0;
etc.

I took a guess, but for this kind of question you should also report (copied-and-pasted) what your test inputs and resulting outputs were.

--
Lew
.