Results 1 to 1 of 1
  1. #1
    just_in_deed is offline Member
    Join Date
    Aug 2010
    Posts
    25
    Rep Power
    0

    Default GradeBook Program

    This program basically asks you to insert how many courses you want to be printed on the screen each one separately then it asks if you want to proceed inserting more. If you don't the program exits.

    this one I wrote in english so there are no more confusions

    do you have any sugestions to optimize the code?

    any comment is welcomed

    --------------------------------------------------------------------------------------------------------------------------

    Main class

    Java Code:
    public class GradeBookTest {
    
    	public static void main(String[] args){
    		
    		instructions important = new instructions();
    		important.read();
    		GradeBook GradeBook1 = new GradeBook();
    		GradeBook1.contador();
    		
    	}
    }
    Class GradeBook

    Java Code:
    import java.util.Scanner;
    public class GradeBook {
    	
    	public String capturename(){
    		
    		Scanner input = new Scanner(System.in);
    		System.out.println("Please enter the course name :\n");
    		String nameOfCourse = input.nextLine();
    		System.out.printf("\nThe course name is : ", nameOfCourse);
    		return nameOfCourse;
    	}
    	
    	public String contador(){
    		
    		Scanner input2 = new Scanner( System.in );
    		System.out.println( "How many courses do you want to register ? " );
    		int cursos = input2.nextInt();
    		for( int a = 0; a < cursos; a++ ){
    			
    			 
    			System.out.println(capturename() );
    		}
    		proceed();
    		return "";
    	}
    	
    	public void proceed(){
    		
    		System.out.println("\nDo you want to add more courses ?\t1 = yes 2 = no");
    		Scanner input3 = new Scanner( System.in );
    		int value = input3.nextInt();
    		
    		if( value == 1 ){
    			
    			contador();
    		}else{
    			
    			System.out.println( "\n\nthanks for using gradebook v1.0" );
    		}
    	}
    	
    }
    Class instructions

    Java Code:
    public class instructions {
    
    	public void read(){
    		
    		System.out.println("\n\n\n\n"+
    		"_______________________________________________________________"+
    		"\n\n"+
    		"Author          ---->     CROATOAN     <----\n\n" +
    		"E-mail   ---->     sauerplayer@hotmail.com     <----\n\n" +
    	    " To use this program you must fisrt indicate\n " +
    	    "how many courses you want to register then write\n " +
    	    "the course name and finally indicate if you want to\n " +
    	    "keep registering more courses\n\n"+
    	    "_______________________________________________________________"+
    	    "\n\n\n\n");
    	}
    Attached Files Attached Files

Similar Threads

  1. Replies: 2
    Last Post: 04-02-2011, 01:57 PM
  2. Replies: 13
    Last Post: 03-22-2011, 07:49 AM
  3. GradeBook Class Modifications
    By awaken38 in forum New To Java
    Replies: 2
    Last Post: 02-07-2011, 10:55 PM
  4. changing my program to array working program
    By Chewart in forum New To Java
    Replies: 39
    Last Post: 11-18-2009, 07:53 PM
  5. Replies: 0
    Last Post: 04-04-2008, 03:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •