+ 1

how to write this code, who can help on skype or here?

//I try to learn java and make an application. please help me on skype: //hamid.mohammadi30@hotmail.com think we have an university: 1.teachers Name, ID 2.students Name, ID 3.chemicals Name, ID, Formula, Cost, Consumption, TotalCost(Cost * Consumption) * each teacher has some students. input of application is: Teacher ID, student ID, chemical ID, chemical Consumption output of application is: teachers Names + chemicals Name + chemicals Consumption + TotalCost students Names + chemicals Name + chemicals Consumption + TotalCost chemicals Name + chemicals Consumption + TotalCost for Example: Teachers{ Jack, ID=100{ Students (Mary, ID = 101), (Robert, ID = 102) } Mick, ID=120{ Students (Anderson, ID = 121) } } Chemicals{ Name =Sodium Chloride, ID=1, Formula = NaCl, Cost = 0.2$ Name =Sodium Hydroxide, ID=2, Formula = NaOH, Cost = 1.2$ } Mary consume 25 grams of NaCl Robert consume 8 grams of NaOH Anderson consume 13 grams of NaCl input: 100, 101, 1, 25 100, 102, 2, 8 120, 121, 1, 13 output1 (Teachers): jack Sodium Chloride 25 gr 5$ Sodium Hydroxide 8 gr 9.6$ ------------------------------------ Total Cost 14.6$ Mick Sodium Chloride 13 gr 2.6$ ------------------------------------ Total Cost 2.6$ output2 (Students): Mary Sodium Chloride 25 gr 5$ Robert Sodium Hydroxide 8 gr 9.6$ Anderson Sodium Chloride 13 gr 2.6$ output3 (Chemicals): Sodium Chloride 38 gr 7.6$ Sodium Hydroxide 8 gr 9.6$

24th May 2017, 4:36 PM
hamid
hamid - avatar
11 Respostas
+ 9
create an overriding toString method 😊 https://www.sololearn.com/discuss/396590/?ref=app
26th May 2017, 9:27 AM
NimWing Yuan
NimWing Yuan - avatar
+ 6
public class Teacher { } public class Student { } public class Chemical { }
24th May 2017, 5:02 PM
NimWing Yuan
NimWing Yuan - avatar
+ 6
// done : class details // to do : print report package chemistry; import java.util.ArrayList; public class University { public static void main ( String [ ] args ){ ArrayList <Student> lstStud = new ArrayList <>(); lstStud.add (new Student("Mary",101)); lstStud.add (new Student("Robert",102)); lstStud.add (new Student("Anderson",121)); ArrayList <Chemical> lstChem = new ArrayList <>(); lstChem.add (new Chemical("Sodium Chloride",1, "NaCl", 0.1)); lstChem.add (new Chemical("Sodium Hydroxide",2,"NaOH",1.2)); ArrayList <Teacher> lstTeach = new ArrayList <>(); lstTeach.add (new Teacher("Jack",100)); lstTeach.add.get (0).addStudent(lstStud.get (0)); lstTeach.add.get (0).addStudent(lstStud.get (1)); lstTeach.add (new Teacher("Mick",120)); lstTeach.add.get (1).addStudent(lstStud.get (2)); } } class Identity { private String name; private int id; public Identity (String name, int id){ this.name= name; this.id=id; } } class Student extends Identity{ public Student (String name, int id){ super (name,id); } class Teacher extends Identity { ArrayList <Student> listStudent = new ArrayList <>(); public Teacher (String name, int id){ super (name, id); } void addStudent (Student student){ listStudent.add (student); } } class Chemical extends Identity { private String formula; private double cost; public Chemical (String name, int id, String formula, double cost){ super (name,id); this.formula= formula; this.cost= cost; } }
25th May 2017, 10:35 AM
NimWing Yuan
NimWing Yuan - avatar
+ 5
Nice question. general advice Try to create classes for Teacher Student and Chemicals add the appropiate attributes for your classes add the appropiate behavior for your classes
24th May 2017, 4:42 PM
NimWing Yuan
NimWing Yuan - avatar
+ 3
Output is information about lstTeach which is an ArrayList of Teacher objects. For every object you get the information about: package name = chemistry . = separation sign class name = Teacher @ = separation sign 1db9742 = hashcode hexadecimal.
26th May 2017, 7:39 AM
NimWing Yuan
NimWing Yuan - avatar
+ 2
anybody don't help with details here :(((( I'm beginner in java.
24th May 2017, 2:02 PM
hamid
hamid - avatar
+ 1
creating class is simple unit of that, after that?
24th May 2017, 5:25 PM
hamid
hamid - avatar
+ 1
how can get this arraylists information? for example all teachers name or al students name?
26th May 2017, 9:00 AM
hamid
hamid - avatar
0
ok, I ask here
24th May 2017, 3:40 PM
hamid
hamid - avatar
0
I'm beginner in java and I try to create this Classes more than 5 times, but cant give aim.
24th May 2017, 4:54 PM
hamid
hamid - avatar
0
thank you NimWing Yuan. please try to add this statement and run app System.out.println(lstTeach); output: [chemistry.Teacher@1db9742, chemistry.Teacher@106d69c] what is it?
25th May 2017, 10:49 PM
hamid
hamid - avatar