Results 1 to 10 of 10
Like Tree2Likes
  • 1 Post By KevinWorkman
  • 1 Post By quad64bit

Thread: I want to know if this is possible with java?

  1. #1
    luckycharm is offline Member
    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0

    Default I want to know if this is possible with java?

    Our professor is expecting us to be expert in java and want's us to do this:
    =============================================

    Class Record Menu

    [1] Initialize class record

    [2] Enter student entry

    [3] Show class record

    [4] Delete student entry

    [5] Edit student entry

    [6] Show answers to essay questions

    [0] Exit

    =============================================

    1. Initialize class record

    Ask the user the size of the class record (number of students) and how many grades are to be stored per student. This is only executed once. If the user attempts to select this option for the second time, access to this option should be denied.

    Enter class size: 10

    Enter number of grades: 5



    2. Enter student entry

    Whenever this option is selected, one student entry is added to the database. Each student entry is composed of student number, surname, firstname, country and his grades (remember, the number of grades to be entered will depend on what the user entered in option 1 – initialize class record). And, you should also compute the average of the grades after all the student’s grades have been entered.

    Student Number : 2002-123

    Surname: Ang

    Firstname: Coolit

    Country: China

    Grade 1: 25.09

    Grade 2: 98.12

    Grade 3: 87.45

    Grade 4: 99.99

    Grade 5: 55.56

    Moreover, remember, that you should alert an error if the user still tries to enter a student entry but the class record size has been reached.



    3. Show class record

    This prints all the student entries, but before printing you have to show a submenu, something similar to this one, to ask which manner of printing should be done.

    [1] According to surname, alphabetical

    [2] According to student number, lowest to highest

    [3] According to grades, highest to lowest

    /* For example, option 1 has been selected */

    Student: 2002-123 | Ang, Coolit | From China

    Grades: 25.09 | 98.12 | 87.45 | 99.99 | 55.56

    Average: 73.24



    Student: 2001-456 | Sun, Tu Kan | From Vietnam

    Grades: 100.00 | 100.00 | 100.00 | 80.00 | 85.00

    Average: 93



    4. Delete student entry

    User may delete a student entry, so ask for the surname of the student entry to be deleted. Alert an error if surname does not exist in the record.



    5. Edit student entry

    User may edit a student entry, so ask for the surname of the student entry to be edited. Alert an error if surname does not exist in the record. Then, print the existing student entry values and ask for the new (edited/modified) student entry values one-by-one. If the user does not enter anything (eg. user only presses the ENTER key or he enters an empty string), that means the value will remain unchanged.

    Enter surname of student entry to be edited: Ang

    Student number: 2002-123

    Enter new student number: 2002-124

    Surname: Ang

    Enter new surname: /* since no new surname is entered, this remains unchanged*/

    …………..

    Grade 5: 55.56

    Enter new grade 5: 100.00

    If any of the grades is changed, the average should be recomputed.



    6. Show answers to essay questions

    In no more than 4 sentences, show your answers to the following essay questions. Just imitate the behaviour (how these should be printed) from Assignment 2, option 1.

    A. Why are primitive data types important?

    B. Clearly differentiate an array from a vector.

    C. Clearly differentiate an array list from a linked list.



    Assumptions

    Assume that all operations involving strings here are case-insensitive.
    Assume that the user will enter unique surnames.

    how do u make a variable based on a loop making an arraylist and a couple of array to be editted later on? This is professional work already. Can you help me with this?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,969
    Rep Power
    8

    Default Re: I want to know if this is possible with java?

    I assure you that this is not professional work. I also advise against wasting time complaining about your educator- many people here learned how to program without a teacher, a classroom, fellow students, books, tutors, or any of the other perks you get from enrolling at a school.

    I'd recommend doing a google search of something like "java for loop" to get started. Read through those tutorials, then post an SSCCE demonstrating what you've tried and where exactly you're stuck.
    quad64bit likes this.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,043
    Rep Power
    20

    Default Re: I want to know if this is possible with java?

    Also take this one step at a time.
    For step 1 you need something like a ClassRecord class.
    Get that working.
    The do step 2.
    etc etc.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: I want to know if this is possible with java?

    So, You Need to Write a Program but Don't Know How to Start

    Yeah, I agree with others, if you think this is the task of an expert, you're in for a rude smack in the face from reality. Programming is hard, and a good professor expects a lot. Your project is really quite trivial in difficulty, so your comments say to me that you haven't invested the necessary time into studying the requirements, the language, and practicing the basics.

    This is professional work already.
    Oh man, I wish it was - if I could get paid to write stuff like this, I could spend most of my time sleeping.

    I think the problem is that you feel overwhelmed at the moment, and thats keeping you from taking a step back and carefully considering what you need to do. All programs consist of many small parts that do simple tasks meshed together to do a more complex task. So the key is divide and conquer. Pick the most preliminary requirement you can find - like user input. Figure out how to get that working. When you do, thats one more thing you don't need to worry about, and one more step towards finishing your app.

    Just a little FYI, the program I have been writing for the past two years professionally is over 40,000 lines of java, groovy, javascript, gsp, sql, html, css, xml, and many others. It references dozens of external libraries, many of which are as big if not bigger than the app itself. Professional work is on a level you cannot even comprehend yet - but you will if you stick with it and don't let moments of desperation get the better of you. Hang in there!
    DarrylBurke likes this.

  5. #5
    lannie1980 is offline Member
    Join Date
    Mar 2012
    Posts
    88
    Rep Power
    0

    Default Re: I want to know if this is possible with java?

    good advice quad ;)

  6. #6
    luckycharm is offline Member
    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0

    Default Re: I want to know if this is possible with java?

    Sorry, this is coming out from my inability to produce anymore working code. I actually did some codes and for some reason I'm stuck. Thank you quad u are a gem(I mean your inspiring words), my teacher doesn't really give me codes but he instead gives me another problem where I get stuck so yes I am forced to learn by myself. This work is actually so overdue I think I'm going to fail it. So, I think I'm just doing this so I learn from it and so I can rule out my feelings of frustration over this homework. Here, is what I've done so far: (I'm going to continue trying to solve this and i hope you can tell me where i did wrong)
    Java Code:
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.util.*;
    import java.util.ArrayList;
    import java.util.Collections;
    
    
    
    public class Yu_A3  {
    private int classize;
    private int numbergrades;
    private double [] arr = new double[numbergrades];
    private ArrayList<String> studentinfo = new ArrayList<String>();
    private double grades;
    private double average, average1, average2;
    private double sum=0;
    private String studentnumber, surname, firstname, country;
    
    
    
    Scanner input = new Scanner(System.in);
    BufferedReader br = new BufferedReader
    (new InputStreamReader(System.in));
    
    
    private void mainMenu() throws Exception {
        int selection;
        System.out.println(" ________________________________________ ");
        System.out.println("|                                        |");
        System.out.println("|          ~Class Record Menu~           |");
        System.out.println("|                                        |");
        System.out.println("|  [x] Initialize Class Record           |");
        System.out.println("|  [1] Enter Student Entry               |");
        System.out.println("|  [2] Show Class Record                 |");
        System.out.println("|  [3] Delete Student Entry              |");
        System.out.println("|  [4] Edit Student Entry                |");
        System.out.println("|  [5] Show Answers to Essay Questions   |");
        System.out.println("|  [6] Exit                              |");
        System.out.println("|________________________________________| ");
        System.out.print("Please select your option: ");
            selection =input.nextInt();
    switch (selection){
        case 1:
            initialize();
            break;
        case 2:
            identification();
            break;
        case 3:
            show();
            break;
        case 4:
        	delete();
        	break;
        case 5:
            edit();
            break;
        case 6:
            essay();
            break;
        case 7:
            exit();
            break;
            
    }
    }
    private void initialize() throws Exception{
    	
    	System.out.println("Enter class size: ");
    	classize = Integer.parseInt(br.readLine());
    	
    	System.out.println("Enter number of grades: ");
    	numbergrades = Integer.parseInt(br.readLine());
    	
    	
    	System.out.print("Class size = ");
    	System.out.print(classize);
    	System.out.print("Number of Grades= ");
    	System.out.print(numbergrades);
        mainMenu();
    } 
    
    
    private void identification()throws Exception {
    	
    	for (int i=0; i<classize; i++){
        System.out.print("Please enter Student Number: ");
        studentnumber = br.readLine();
            
        System.out.print("Please enter Surname: ");
        surname = br.readLine();
        
        System.out.print("Please enter Firstname: ");
        firstname = br.readLine();
        
        System.out.print("Please enter Country: ");
        country = br.readLine();
            
        
                   	for (int j = 0; j < numbergrades; j++) {
            	      System.out.print("grades "+(j+1)+" : " );
            	      grades= input.nextDouble(); //when i input number here i get error
            	      sum += grades;
            	      
            	    }
            	    average = sum / numbergrades;
            	    
            	     
            	    System.out.println(""); 
            	    System.out.println("Average is " + average);
            	     
        studentinfo.add(studentnumber);
        studentinfo.add(surname);
        studentinfo.add(firstname);
        studentinfo.add(country);
        
     
    
    
            
        
    	}
       mainMenu();
    	}
    	
    
    
    private void show() throws Exception{
    		
    	System.out.println("[1] According to surname, alphabetical");
    	System.out.println("[2] According to student number, lowest to highest");
    	System.out.println("[3] According to grades, highest to lowest");
       	int a = Integer.parseInt(br.readLine());
       	
       	switch(a){
       	
       	case 1:
       		
       		Collections.sort(studentinfo); //i cant get this to work as supposed to
       		System.out.println(studentinfo);
       		System.out.println(average);
       		
       		/*for(Object temp : studentinfo){
    			System.out.println(temp);
    		}*/
       		//for(int k=0; k<numbergrades; k++){
       		
       		System.out.println("Choose [1] to see others \n Choose [2] to go to Main Menu");
       	   	int b = Integer.parseInt(br.readLine());
       	   	switch(b){
       	   	
       	   	case 1:
       		show();
       	   	break;
       	
       	    case 2:
       		mainMenu();
       	    break;	
       	   	         }
       	   	
       	case 2:
       		
       		
       		System.out.println("Choose [1] to see others \n Choose [2] to go to Main Menu");
       	   	int c = Integer.parseInt(br.readLine());
       	   	switch(c){
       	   	
       	   	case 1:
       		show();
       	   	break;
       	
       	    case 2:
       		mainMenu();
       	    break;
       		         }
       	case 3:
       		
       		
       		System.out.println("Choose [1] to see others \n Choose [2] to go to Main Menu");
       	   	int d = Integer.parseInt(br.readLine());
       	   	switch(d){
       	   	
       	   	case 1:
       		show();
       	   	break;
       	
       	    case 2:
       		mainMenu();
       	    break;
       	   			 }
       	   	       }
    }
    private void delete() throws Exception{
    	
    	studentinfo.remove(0);
        studentinfo.remove(1);
        studentinfo.remove(2);
        studentinfo.remove(3);
        //studentgrades.remove(0);
    	
        mainMenu();
    }
    
    private void edit() throws Exception{
    	System.out.println("[1] edit student number");
    	System.out.println("[2] edit surname");
    	System.out.println("[3] edit first name");
    	System.out.println("[3] edit country");
       	int a = Integer.parseInt(br.readLine());
       	
       	switch(a){
       	
       	case 1:
       		System.out.println("change student number");
       		studentnumber = br.readLine();
       		studentinfo.set(1, studentnumber);
       		break;	
       	   		
       	case 2:
       		System.out.println("change surname");
       		surname = br.readLine();
       		studentinfo.set(2, surname);
       		break;
       		
       	case 3:
       		System.out.println("change firstname");
       		firstname = br.readLine();
       		studentinfo.set(3, firstname);
       		break;
       	
       	case 4:
       		System.out.println("change country");
       		country = br.readLine();
       		studentinfo.set(4, country);
       	}
    }
    
    private void essay() throws Exception{
    	
    	System.out.println("Specify delay (in milliseconds):");
    	int slp = Integer.parseInt(br.readLine());
        int selection1;
        Thread.sleep(slp);
        System.out.println("A. Why are primitive data types important?");
        System.out.println("Primitive data types are basic building blocks for more even advanced program scripting.");
        System.out.println("");
        Thread.sleep(slp);
        System.out.println("B. Clearly differentiate an array from a vector.");
        System.out.println("Array allows for multi dimensional indexing.");
        System.out.println("While, Vectors are singular.");
        System.out.println("");
        Thread.sleep(slp);
        System.out.println("C. Clearly differentiate an array list from a linked list.");
        System.out.println("Array lists are old fashioned lists that uses the function of an array."); 
        System.out.println("While Linked List allow you for higher number of accessible methods such as add first and add last.");
        System.out.println("");
        Thread.sleep(slp);
        System.out.println("Return to main menu? \n [1] for YES \n");
        
        selection1 =input.nextInt();
    switch (selection1){
        case 1:
            mainMenu();
            break;
       }
    }
    
    
    private void exit(){
    	System.out.println("");
    	System.out.println(" *************************************** ");
    	System.out.println("|                                       |");
    	System.out.println("|                                       |");
    	System.out.println("|    A+ for all students who tried      |");
    	System.out.println("|             their best!               |");
    	System.out.println("|                                       |");
    	System.out.println("|                                       |");
    	System.out.println(" *************************************** ");
    }
    
    
    public static void  main(String[] args) throws Exception {
    	new Yu_A3().mainMenu();
    }
    }
    Last edited by luckycharm; 11-10-2012 at 11:25 AM.

  7. #7
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,969
    Rep Power
    8

    Default Re: I want to know if this is possible with java?

    What does that code do? Does it work? Does it throw an Exception? Does it compile?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  8. #8
    luckycharm is offline Member
    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0

    Default Re: I want to know if this is possible with java?

    yes it does compile under eclipse try to paste them i get error in the when i input the grades. Btw, u have to do this 1 by 1 meaning from steps 1, then 2 then 3.

  9. #9
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,043
    Rep Power
    20

    Default Re: I want to know if this is possible with java?

    What error do you get?
    You cannot expect us to run your code to find the problem.

    Provide the full exception text plus stack trace and highlight the line on which it occurs.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  10. #10
    luckycharm is offline Member
    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0

    Default Re: I want to know if this is possible with java?

    I found the error thanks to my prof i shouldve initialized array in line 75 instead in line 12. This program isn't finished yet, I need my program to output like this:

    Student: 2002-123 | Ang, Coolit | From China

    Grades: 25.09 | 98.12 | 87.45 | 99.99 | 55.56

    Average: 73.24

    is it possible with arrays, I tried but failed making arr[studentnumber][surname][firstname][country] because dimensions should have the array.size in it not inputs. So, what I did is store it in an arraylist in line 112-115
    <code>
    studentinfo.add(studentnumber);
    studentinfo.add(surname);
    studentinfo.add(firstname);
    studentinfo.add(country);
    </code>
    But I can't make them look like as required. I asked my professor if i could make loop to make new arraylists, he is unsure too with that, so how do i do that? And also do the sorting out:

    [1] According to surname, alphabetical

    [2] According to student number, lowest to highest

    [3] According to grades, highest to lowest
    i only know bubble.sort

Posting Permissions

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