Jump to content
JamesBong

Ajutor program java

Recommended Posts

Posted (edited)

Salut

 

Am de facut pentru facultate un program in Java si anume sistem pentru inregistrarea studentilor unei facultati.  Nu vreau sa scrie cineva programul pentru mine, am nevoie de ghidare, daca sunteti amabili.

Screen_Shot_2018_07_12_at_21_00_42.pngScreen_Shot_2018_07_12_at_21_00_58.png

 

 

Si iata ce am facut eu pana acum :

 


public class Student {

	private static String[] firstname;
	private static String[] surname;
	private static String[] course;
	private static String[] adress;
	private static String[] tel;
	private static String[] email;
	private static String[] dob;
	private static String[] country;
	private static int[] fees, id;
	private static int n = 0;
	private static int idn = 10000; 
	private static int studentCount = 0;
	
	public static void addStudent(String fn, String sn, String crse, String adr, String tel_,
			String mail, String db, String ctry)
	{
		
		firstname[n] = fn;
		surname[n] = sn;
		course[n] = crse;
		adress[n] = adr;
		tel[n] = tel_;
		email[n] = mail;
		dob[n] = db;
		country[n] = ctry;
		id[n] = idn + 1;
		fees[n] = 9000;
		studentCount++;
		idn++;
		n++;
	}
	
	public static void listStudent()
	{
		for(n = 0; n < studentCount; n++)
		{
			System.out.printf("%s %s %s %s %s %s %s %s %d %d%n ", firstname[n], surname[n],
				course[n], adress[n], tel[n], email[n], dob[n], country[n], id[n], fees[n] );
		}
	}
}

 

import java.util.Scanner;

public class StudentTest {

	static Scanner input = new Scanner(System.in);

	
	public static void main(String[] args)
	{
		
		menu();
		
	}
	public static void menu()
	{
		byte choice;
		
		
			
		System.out.println("*************************");
		System.out.println("* Bright Future College *");
		System.out.println("*************************");
		System.out.println("1. Enroll student");
		System.out.println("2. Pay fees");
		System.out.println("3. List students on a course");
		System.out.println("4. Change course");
		System.out.println("5. View student profile");
		System.out.println("6. Remove student from course");
		System.out.println("7. ****Management reporting****");
		System.out.println("8. Exit");
		choice = input.nextByte(); input.nextLine();
		
		switch(choice)
		{
		case 1:
			enroll();
			menu();
			break;
			
		case 3:
			Student.listStudent();
			
		default:
			System.out.println("Please enter a valid option!");
			menu();
			
		}
		
	}
	
	public static void enroll()
	{
		System.out.println("Please enter the first name: ");
		String fn = input.nextLine();
		System.out.println("Please enter the surname: ");
		String sn = input.nextLine();
		System.out.println("Please enter the course: ");
		String crse = input.nextLine();
		System.out.println("Please enter the full adress: ");
		String adr = input.nextLine();
		System.out.println("Please enter the telephone number: ");
		String tel_ = input.nextLine();
		System.out.println("Please enter the email: ");
		String mail = input.nextLine();
		System.out.println("Please enter the date of birth: ");
		String db = input.nextLine();
		System.out.println("Please enter the type of student(home or foreign ");
		String ctry = input.nextLine();
		Student.addStudent( fn,  sn,  crse,  adr,  tel_,
				 mail,  db, ctry);
	}
	
}

Asta am facut pentru inceput.

Nu stiu exact cum sa inregistrez studenti noi, sau cum sa chem metoda din alta clasa sa inregistrez studenti.

 

Orice sfat ar fi foarte apreciat.

Edited by JamesBong
Posted

Hai ca te luam usor.. deci, nu cred te ajuta nimeni pt facultate pe forumul asta, e datoria ta sa inveti. Acel "static" inseamna ca pentru fiecare obiect in java i se atribuie aceeasi valoare, google poate explica mai bine la ce ma refer.

Posted

Vai de java ta. Esti anul 1?

 

Daca esti anul 2 nu prea e bine de tine. Mai bine te duci la arte sau finante.

 

Da un google despre OOP (Programarea Orientata pe Obiecte)

 

Vezi ca un Student poate fi o clasa.

Un campus poate fi o clasa.

Poti face o colectie de studenti intr-un campus.

Un curs poate fi o clasa.

Poti face o relatie reflexiva intre curs-student.

 

Posted

Nu prea e bine. Puteai sa faci campurile sa nu fie statice si atribuiai cu constructorul tot ce trebuie, practic faceai un student nou cand faceai un obiect nou. Ce ai facut tu nu e bine.

Posted
20 minutes ago, JamesBong said:

.profesorul ne citeste materialul de curs si nu ne da exemple sa intelegem principiile.

 

Banuiesc ca nu ai vreo dizabilitate/handicap si ai gura sa poti intreba si cere? Ca de aia e platit.

  • Active Members
Posted
3 hours ago, JamesBong said:

Va multumesc tuturor pentru raspunsuri....O sa citesc din nou despre metode si clase si un crash course despre java.

Doar de curiozitate intreb. Cum esti in saptamana 4 pe 15 Iulie?

  • Upvote 1
Posted

Am facut cateva modificari la cod si acum primesc urmatoarea eroare dupa ce bag datele la enroll student si nu imi dau seama cum o pot rezolva.

Screen_Shot_2018_07_13_at_20_54_45.png


public class Student {
	
	private   String[] firstname;
	private   String[] surname;
	private   String[] course;
	private   String[] adress;
	private   String[] tel;
	private   String[] email;
	private   String[] dob;
	private   String[] country;
	private   int[] fees;
	private   int[] id;
	private   int n = 0;
	private   int idn = 10000; 
    int studentCount = 0;
	
	public Student(String fn, String sn, String crse, String adr, String tel_,
			String mail, String db, String ctry)
	{
		
	    firstname[n] = fn;
		surname[n] = sn;
		course[n] = crse;
		adress[n] = adr;
		tel[n] = tel_;
		email[n] = mail;
		dob[n] = db;
		country[n] = ctry;
		id[n] = idn + 1;
		fees[n] = 9000;
		studentCount++;
		idn++;
		n++;
	}
	
	public void listStudent()
	{
		for(int x = 0; x < studentCount; x++)
		{
			System.out.printf("%s %s %s %s %s %s %s %s %d %d%n ", firstname[n], surname[n],
				course[n], adress[n], tel[n], email[n], dob[n], country[n], id[n], fees[n] );
			
		}
	}
}

 

 

import java.util.Scanner;

public class StudentTest {

	static Scanner input = new Scanner(System.in);

	
	public static void main(String[] args)
	{
		
		menu();
		
	}
	public static void menu()
	{
		byte choice;
		
		System.out.println("*************************");
		System.out.println("* Bright Future College *");
		System.out.println("*************************");
		System.out.println("1. Enroll student");
		System.out.println("2. Pay fees");
		System.out.println("3. List students on a course");
		System.out.println("4. Change course");
		System.out.println("5. View student profile");
		System.out.println("6. Remove student from course");
		System.out.println("7. ****Management reporting****");
		System.out.println("8. Exit");
		choice = input.nextByte(); input.nextLine();
		
		switch(choice)
		{
		case 1:
			enroll();
			menu();
			break;			
		case 3:
			//Student.listStudent();	
		default:
			System.out.println("Please enter a valid option!");
			menu();	
		}
	}
	
	public static void enroll()
	{
		System.out.println("Please enter the first name: ");
		String fn = input.nextLine();
		System.out.println("Please enter the surname: ");
		String sn = input.nextLine();
		System.out.println("Please enter the course: ");
		String crse = input.nextLine();
		System.out.println("Please enter the full adress: ");
		String adr = input.nextLine();
		System.out.println("Please enter the telephone number: ");
		String tel_ = input.nextLine();
		System.out.println("Please enter the email: ");
		String mail = input.nextLine();
		System.out.println("Please enter the date of birth: ");
		String db = input.nextLine();
		System.out.println("Please enter the type of student(home or foreign ");
		String ctry = input.nextLine();
		Student student = new Student(fn, sn, crse, adr, tel_, mail, db, ctry);
	}
	
}

Un sfat va rog.

 

Posted (edited)

DE CE DUMNEZEII MASII TOT VAD 

String[] nume;

 

Ma omoara! Vai de pula voastra daca intelege careva ce cacat e String[] r(e o declaratie neinitializata de un array de stringuri)

 

Uite fa asa in pula mea:

 

public class Student{

public String nume;

Student(String name){

nume=name;

}

 

 

public class StudentTest{

 

pula mea main()

{

Student student1 = new Student("Vasili");

Student student2= new Student("Amariei");

//Baga student 1 si 2 intr-un array

 

//fa un array de studenti

Student[] listaStudenti = new Student[10];

 

//baga-l in array

listaStudenti[0]=student1;

 

//CITESTE IN PLM CE E ALA OOP!!!

}

 

Sfat:

Petrece 4-5 zile fara sa lucrezi la cacatul tau de proiect. Petrece timpul ala invatand ce e OOP. Joaca-te cu niste exemple simple de pe google si incearca sa intelegi cum merge treaba.

 

 Nu poti sa sari de la 0 si sa faci proiectul din prima. Daca investesti timp pentru tine, ca sa inveti inainte sa te apuci sa faci un cacat, ai sanse sa construiesti un proiect acceptabil.

Edited by yoyois
  • Upvote 1
Posted
11 hours ago, yoyois said:

Vai de pula voastra daca intelege careva ce cacat e String[]

Man, daca nu petrece timp studiind putin si sare si face totul dupa ureche...

Posted

Salut. Va multumesc pentru sfaturi....foarte constructive :)) ..... Am facut un alt program prin care sa invat despre arrayList si cand dau enroll student cumva sare peste firstName si inregistreaza doar surname. Am tot incercat sa ii dau de cap si nu reusesc.

 

import java.util.Scanner;
import java.util.ArrayList;

public class arrayList {

    static Scanner input = new Scanner(System.in);
	static ArrayList<String> firstName = new ArrayList<String>();
	static ArrayList<String> surname = new ArrayList<String>();
	
	public static void main(String[] args)
	{
		menu();
	}
	
	public static void menu()
	{
		byte choice;
		System.out.println("Main menu");
		System.out.println("*********");
		System.out.println("1. Enroll student");
		System.out.println("2. List students");
		System.out.println("Make a choice: ");
		choice = input.nextByte();
		
		switch(choice) {
		case 1:
			enroll();
			System.out.println("You have successfully added a student.");
			System.out.println();
			menu();
			break;
			
		case 2:
			list();
			menu();
			break;
		default:
			System.out.println("Please make a valid choice.");
			System.out.println();
			menu();
			break;
		}	
	}
	
	public static void list() {
		int n = 1;
		for(int x = 0; x < firstName.size();x++)
		{
			System.out.println(n + ". " + firstName.get(x) + " " + surname.get(x));
			n++;
		}
	}
	
	public static void enroll() {
		String fn, sn;
		System.out.println("Please enter the first name:");
		fn = input.nextLine();
		
		System.out.println("Please enter the surname:");
		sn = input.nextLine();
		
		firstName.add(fn);
		surname.add(sn);
		
	}
}

 

 

Screen_Shot_2018_07_15_at_22_43_26.png

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...