Hey there everyone. I David. I am have a problem with the end of line keystroke ( Ctrl+Z ) in the Netbeans and JBuilder Compiler, when I press the buttons simultaneously nothing happens but when I do it in Eclipse it works fine. Here is a look at the code.Help is gladly appreciated.

/*
 * Gradebook.java
 *
 * Created on July 5, 2009, 10:41 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

/**
 *
 * @author David
 */
import java.util.Scanner;

public class Gradebook 
{
    
    private String courseName;
    private int gradeTotal = 0;
    private int gradeCounter = 0;
    private int aCount = 0;
    private int bCount = 0;
    private int cCount = 0;
    private int dCount = 0;
    private int fCount = 0;
    
    //class constructor initializing variables
    public Gradebook ( String name )
    {
        courseName = name;
    }//end of contructor
    
    //assigns value to course name
    public void setCourseName ( String name )
    {
        courseName = name;
    }//end of method
    
    //retrieves and displays course name 
    public String getCourseName ()
    {
        return courseName;
    }//end of method
    
    //Determines class average
    public void inputGrades ()
    {
        //create scanner to obtain input from user
        Scanner input = new Scanner ( System.in );
        
        int grade; //initializes and declare variable
      
        System.out.printf ( "%s\n%s\n", 
        	                "Enter grades in the range 0 - 100.",
        	                "To exit entry type the end-of-line input (Ctrl + z),then press enter ");
        
        
        //loops while condition is not met
        while ( input.hasNext() )
        {
           grade = input.nextInt();
           gradeTotal = gradeTotal + grade;
           ++gradeCounter;
        
          incrementLetterGradeCounter ( grade );      
       }
    } 
    	
    
    public void incrementLetterGradeCounter ( int score )
    {
    	switch ( score / 10 )
    	{
    		case 9:
    		case 10:
    			++aCount;
    			break;
    			
    		case 8:
    			++bCount;
    			break;
    			
    		case 7:
    			++cCount;
    			break;
    			
    		case 6:
    			++dCount;
    			break;
    			
    		default:
    			++fCount;
    			break;
    	}
    		
    }
        
    //displays a welcome message to the user
    public void displayMessage () 
    {
        System.out.printf ( "Welcome to the gradebook for:\n%s!\n" , getCourseName () );
    }//end of method displaymessage
   
    //Displays report card for class
    public void gradeReport ()
    {
    	double average = 0;
    	
    	System.out.print ( "Grade Report:" );
    	
    	if ( gradeCounter != 0 )
        {		
         	average = ( double ) gradeTotal / gradeCounter; //Calculates class average
        	System.out.printf ( "The total of the %d grades entered is:%d\n", gradeCounter, gradeTotal );
            System.out.printf ( "\nThe Class average is:%.2f", average );
            System.out.printf ( "%s\n\n%s%d\n%s%d\n%s%d\ns%d\ns%d\n",
            	"The number of students who received each grade",
            	"A: ",aCount,
            	"B: ",bCount,
            	"C: ",cCount,
            	"D: ",dCount,
            	"F: ",fCount );
        }
        else
        	  System.out.print ( "No grades were entered" );
    	
    } 

}
 /*//Checks if any grades were entered
        
    */
/*
 * GradeTest.java
 *
 * Created on July 5, 2009, 11:08 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

/**
 *
 * @author David
 */


public class GradeTest 
{
 
    public static void main ( String args [] ) 
    {
        
        
        //create an object of the class gradebook and assign it to mygradebook
        Gradebook myGradeBook = new Gradebook ( "Computer Science" );
        
        myGradeBook.displayMessage();
        myGradeBook.inputGrades();
        myGradeBook.gradeReport();
        
    }
    
}

Recommended Answers

All 2 Replies

IDE provides output window but it is not a console command prompt. So try to run your console application at command prompt.

commented: Super! +1

IDE provides output window but it is not a console command prompt. So try to run your console application at command prompt.

Thank you very much for clearing that up. But I must ask though, how comes Eclipse's IDE allows for that specific keystore?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.