Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: How to fulfill this program

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    11
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default How to fulfill this program

    Hello java members i got a programm to complete and im a lil bit confused.Let me explain you somethings first.I got some classes like UniversityDepartment & PolytechnicDepartment these 2 classes extends *AcademicDepartment* class.And the problem want me to do this.The AcademicDepartment can have pre-graduate program & after-graduate program.And the departments will be 2 University & Polytechnic.For a department to be polytechnic or University depending on the number of labs that have in pre-gruduate program.So if we are in pre-graduate or after-graduate program i think the user must type it from keyboard and if we are in pre-graduate we also must be asked how many labs we got to see if we are in polytechnic or university.So How i will do this?.I will give u an example of my code.



    import java.io.*;
     
    public class  AcademicDepartment {
     
     
    	private String names;
    	private String labs;
    	private int teachers;
    	private int graduates;
    	private boolean studies;
     
     
     
     
     
     
     
     
    	public void infostudies() throws IOException{
    	    System.out.println("Enter the department you want.Press 1 for pre-graduate program  or 2 for after-graduate program" );  
    	    boolean studies = "";  
    	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  
    	    studies = br.readLine(); 
     
    	    if (studies == 1){
    	    		System.out.println("You are in pre-graduate program");
    			   System.out.println("Enter the number of labs");
    			   String labs = ""; 
    			   BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));
    			   labs = br1.readLine();
     
    			   if (labs > 5){
     
    				   System.out.println("The department is polytechnic");
    			   }
     
     
     
    		    }	    
     
    		    if (studies < 5 ){
     
    		    	System.out.println("The department is University");
     
    		    }
    		    else
    		    {
     
    		    	System.out.println("Wrong number try again");
    		    }
    	}    
     
     
    	public AcademicDepartment(String names,String labs,int teachers,int graduates){
     
    		names = new String(names);
    		this.labs = labs;
    		this.teachers = teachers;
    		this.graduates = graduates;
     
    	}
     
     
     
    	public void printdepartmentinfo(){
     
    		System.out.println("The names are:" + names);
    		System.out.println("The labs are:" + labs);
    		System.out.println("The GRADUATES are:" + graduates);
    		System.out.println("The teachers are:" + teachers);
     
    	}
     
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to fulfill this program

    Read the API doc for the readLine() method to see what it does and what type of data it returns. http://docs.oracle.com/javase/7/docs/api/

    It looks like there are many compiler errors that need to be fixed. Copy the full text of the compiler error messages and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Invoke a Java program with windows program
    By jackhard in forum Object Oriented Programming
    Replies: 1
    Last Post: February 21st, 2013, 07:16 AM
  2. Program goes into infinite compilation. University project - Library Program.
    By clarky2006 in forum What's Wrong With My Code?
    Replies: 35
    Last Post: November 10th, 2012, 03:56 PM
  3. Replies: 1
    Last Post: July 8th, 2012, 10:23 AM
  4. how to run a java program..when the program using jar
    By miriyalasrihari in forum Java Theory & Questions
    Replies: 2
    Last Post: May 17th, 2012, 10:04 AM
  5. Program to launch and mirror another program
    By hayate in forum Java Theory & Questions
    Replies: 13
    Last Post: March 9th, 2012, 12:47 AM