import java.util.Scanner;
public class Student {

        private String FirstName;
        private String LastName;
        private String Address;
        private String PhoneNumber;
        private int Credits;
        private double Tuition;
        double Health_Care;
        double Late_Fee;
        double Meal_Plan;
        double TotalTuition;
        double IncidentalFee;
        private boolean state; 
        private boolean LateFee;
        private boolean CampusFood;
        private boolean HealthCare;

        public Student()
        {

        }

    public Student(String studentFirstName, String studentLastName, String studentAddress,String studentPhoneNumber, int studentCredits, double studentTuition, double studentHealth_Care, double studentLate_Fee, double studentMeal_Plan, double studentTotalTuition, double studentIncidentalFee, boolean studentstate, boolean studentLateFee, boolean studentCampusFood, boolean studentHealthCare)
           {
            FirstName = studentFirstName;
            LastName = studentLastName;
            Address = studentAddress;
            PhoneNumber = studentPhoneNumber;
            Credits = studentCredits;
            Tuition = studentTuition;
            Health_Care = studentHealth_Care;
            Late_Fee = studentLate_Fee;
            Meal_Plan = studentMeal_Plan;
            TotalTuition = studentTotalTuition;
            IncidentalFee = studentIncidentalFee;
            state = studentstate;
            LateFee = studentLateFee;
            CampusFood = studentCampusFood;
            CampusFood = studentHealthCare;
           }
    // Set Methods
    void FirstName (String studentFirstName)
    {
        FirstName = studentFirstName;
    }
    void LastName (String studentLastName)
    {
        LastName = studentLastName;
    }
    void Address (String studentAddress)
    {
        Address = studentAddress;
    }
    void PhoneNumber (String studentPhoneNumber)
    {
        PhoneNumber = studentPhoneNumber;
    }
    void Credits (int studentCredits)
    {
        Credits = studentCredits;
    }
    void Tuition (double studentTuition)
    {
        Tuition = studentTuition;
    }
    void Health_Care (double studentHealth_Care)
    {
        Health_Care = studentHealth_Care;
    }
    void Late_Fee (double studentLate_Fee)
    {
        Late_Fee = studentLate_Fee;
    }
    void Meal_Plan (double studentMeal_Plan)
    {
        Meal_Plan = studentMeal_Plan;
    }
    void TotalTuition (double studentTotalTuition)
    {
        TotalTuition = studentTotalTuition;
    }
    void IncidentalFee (double studentIncidentalFee)
    {
        IncidentalFee = studentIncidentalFee;
    }
    void state (Boolean studentstate)
    {
        state = studentstate;
    }
    void LateFee (Boolean studentLateFee)
    {
        LateFee = studentLateFee;
    }
    void CampusFood (Boolean studentCampusFood)
    {
        CampusFood = studentCampusFood;
    }
    void HealthCare (Boolean studentHealthCare)
    {
        HealthCare = studentHealthCare;
    }
    // Get Method
    String FirstName()
    {
        return FirstName;
    }
    String LastName()
    {
        return LastName;
    }
    String Address()
    {
        return Address;
    }
    String PhoneNumber()
    {
        return PhoneNumber;
    }
    int Credits()
    {
        return Credits;
    }
    double Tuition()
    {
        return Tuition;
    }
    double Health_Care()
    {
        return Health_Care;
    }
    double Late_Fee()
    {
        return Late_Fee;
    }
    double Meal_Plan()
    {
        return Meal_Plan;
    }
    double TotalTuition()
    {
        return TotalTuition;
    }
    double IncidentalFee()
    {
        return IncidentalFee;
    }
    boolean state()
    {
        return state;
    }
    boolean LateFee()
    {
        return LateFee;
    }
    boolean CampusFood()
    {
        return CampusFood;
    }
    boolean HealthCare()
    {
        return HealthCare;
    }

    public void readInput()
    {
    Scanner sc=new Scanner(System.in);
    System.out.println("Enter first name");
    FirstName=sc.next();
    System.out.println("Enter last name");
    LastName=sc.next();
    System.out.println("Enter address");
    Address=sc.next();
    System.out.println("Enter phone number");
    PhoneNumber=sc.next();
    System.out.println("Enter the credits you are taken");
    Credits=sc.nextInt();
    System.out.println("Do you Qualify for the instate rate? Enter True for yes or False for no");
    state = sc.nextBoolean();
    System.out.println("Late fee assessed? Enter True for yes or False for no");
    LateFee=sc.nextBoolean();
    System.out.println("Do you want a meal plan? Enter True for yes or False for no");
    CampusFood=sc.nextBoolean();    
    System.out.println("Do you want Health Care? Enter True for yes or False for no");
    HealthCare=sc.nextBoolean();
    }

    public void calculateData()
    {
        if (state == true)
    {
                        if (Credits < 12)
                            Tuition =  (Credits*102.50);
                        }   
    {
                        if(Credits>11 || Credits<19);
                            Tuition = (Credits* 75.45);     
                        }
    {
                        if (Credits>18)
                            Tuition = (Credits*93.00);
                        }
     if (state == false)
    {
         if (Credits < 12)
                Tuition = (Credits*351.00);
    }
     {
            if(Credits>11 || Credits<19);
                Tuition = (Credits* 255.00);
     }
     {
            if (Credits>18)
                Tuition = (Credits*304.00); 
    }


        if (LateFee == true)
        {
            Late_Fee = Tuition/10;
        }
        if (CampusFood == true)
        {
            Meal_Plan = 3499.00;
        }
        if(HealthCare == true)
            {
                if (Credits < 11)
                    Health_Care =  25.00;
                }   
{
                if(Credits>10 || Credits<16);
                    Health_Care = 20.00;        
                }
{
                if (Credits>15)
                    Health_Care = 15.00;
                }
{
IncidentalFee = Credits * 20;
}
{
    TotalTuition = Tuition + Late_Fee + IncidentalFee + Health_Care + Meal_Plan;
}    
}
    public void writeOutput()
    {
        System.out.println("Name: " + FirstName + " " + LastName);
        System.out.println("Address: " + Address);
        System.out.println("PhoneNumber: " + PhoneNumber);
        System.out.println("Credits: " + Credits);
        System.out.println("Tuition: " + Tuition);
        System.out.println("Late Fee: " + Late_Fee);
        System.out.println("Incedental: " + IncidentalFee);
        System.out.println("Health Care: " + Health_Care);
        System.out.println("Meal Plane: " + Meal_Plan);
        System.out.println("Total: " + TotalTuition);
}
}       

public class University 
{
        Student[] s;
        static int a=0;
        public void collectDataForReport(Student person)
        {
        s[a]=person;
        a++;
        }
        public void printDataForSchoolReport()
        {
        System.out.println("UNIVERSITY OF COMPUTERS::");
        System.out.println("Number of students-"+(++a));
        double totalMealPlan=0;
        double totalTuition=0;
        double totalLateFee=0;
        double totalIncidentalFee=0;
        double totalHealthCare=0;
        for(int i=0;i<a;i++)
        {
        totalMealPlan+=s[i].Meal_Plan;
        totalTuition+=s[i].TotalTuition;
        totalLateFee=s[i].Late_Fee;
        totalIncidentalFee=s[i].IncidentalFee;
        totalHealthCare=s[i].Health_Care;
        }
        System.out.println("Total Meal Plan:"+totalMealPlan);
        System.out.println("Total Tuition"+totalTuition);
        System.out.println("Total Late Fee"+totalLateFee);
        System.out.println("Total Incidental"+totalIncidentalFee);
        System.out.println("Total Health Care"+totalHealthCare);
        }
    }

...

import java.text.NumberFormat;
import java.io.*;
import java.util.Scanner; 
public class Tuition 
{
public static void main(String[] args) 
{

                NumberFormat moneyFormatter = NumberFormat.getCurrencyInstance();
                System.out.println(moneyFormatter.format(2003.4));
                String money = moneyFormatter.format(20043.44);
                System.out.println(money);
                University clerk = new University();
                Student person =  new Student();
                int numberOfStudents,i,count;
                System.out.println("Enter number of students:");
                Scanner scan = new Scanner(System.in); 
                numberOfStudents = scan.nextInt();
                for(i=0;i<numberOfStudents;i++)
                {
                    person.readInput();
                    person.calculateData();
                    person.writeOutput();
                    clerk.collectDataForReport(person);
                }
                clerk.printDataForSchoolReport();
    } 
}

The problems I am having are when the user says True to the question "Do you want a meal plan?" The user then has to pick between 3 meal plan options. The options are meal plan stuff-your-face(4999.00), meal plan I-can't-stand-this-food(3499.00), and meal plan I'm-on-a-diet(2599.00). I'm not sure how to implement this into my student class. My main class also isn't running properly. If I put any numbers in my address I get an error. The main class also asks me to enter my phone number and to enter the credits you are taken at the same time without allowing me to answer the phone number question first. Any help and tips for my project would be greatly appreciated!

Edited 3 Years Ago by diafol: fixed formatting

I don't know if it affects much but at line 41 in your Student class should be assigned to HealthCare variable.

I'll try to look for more error.

import java.util.Scanner;

public class Student {

	private String firstName;
	private String lastName;
	private String address;
	private String phoneNumber;
	private int credits;
	private double tuition;
	private double healthCare;
	private double lateFee;
	private double mealPlan;
	private String mealOption;
	private double totalTuition;
	private double incidentalFee;
	private boolean state;
	private boolean lateFeeBoolean;
	private boolean campusFood;
	private boolean healthCareBoolean;
	
	public Student() {
		this("", "", "", "", 0, 0.0, 0.0, 0.0, 0.0, "", 0.0, 0.0, false, false, false, false);
	}
	public Student(String studentFirstName, String studentLastName, String studentAddress, String studentPhoneNumber, int studentCredits, double studentTuition, double studentHealthCare, double studentLateFee, double studentMealPlan, String studentMealOption, double studentTotalTuition, double studentIncidentalFee, boolean studentState, boolean studentLateFeeBoolean, boolean studentCampusFood, boolean studentHealthCareBoolean) {
		setFirstName(studentFirstName);
		setLastName(studentLastName);
		setAddress(studentAddress);
		setPhoneNumber(studentPhoneNumber);
		setCredits(studentCredits);
		setTuition(studentTuition);
		setHealthCare(studentHealthCare);
		setLateFee(studentLateFee);
		setMealPlan(studentMealPlan);
		setMealOption(studentMealOption);
		setTotalTuition(studentTotalTuition);
		setIncidentalFee(studentIncidentalFee);
		setState(studentState);
		setLateFeeBoolean(studentLateFeeBoolean);
		setCampusFood(studentCampusFood);
		setHealthCareBoolean(studentHealthCareBoolean);
	}
	
	void setFirstName(String studentFirstName) {
		firstName = studentFirstName;
	}
	void setLastName(String studentLastName) {
		lastName = studentLastName;
	}
	void setAddress(String studentAddress) {
		address = studentAddress;
	}
	void setPhoneNumber(String studentPhoneNumber) {
		phoneNumber = studentPhoneNumber;
	}
	void setCredits(int studentCredits) {
		credits = studentCredits;
	}
	void setTuition(double studentTuition) {
		tuition = studentTuition;
	}
	void setHealthCare(double studentHealthCare) {
		healthCare = studentHealthCare;
	}
	void setLateFee(double studentLateFee) {
		lateFee = studentLateFee;
	}
	void setMealPlan(double studentMealPlan) {
		mealPlan = studentMealPlan;
	}
	void setMealOption(String studentMealOption) {
		mealOption = studentMealOption;
	}
	void setTotalTuition(double studentTotalTuition) {
		totalTuition = studentTotalTuition;
	}
	void setIncidentalFee(double studentIncidentalFee) {
		incidentalFee = studentIncidentalFee;
	}
	void setState(boolean studentState) {
		state = studentState;
	}
	void setLateFeeBoolean(boolean studentLateFeeBoolean) {
		lateFeeBoolean = studentLateFeeBoolean;
	}
	void setCampusFood(boolean studentCampusFood) {
		campusFood = studentCampusFood;
	}
	void setHealthCareBoolean(boolean studentHealthCareBoolean) {
		healthCareBoolean = studentHealthCareBoolean;
	}
	
	String getFirstName() {
		return firstName;
	}
	String getLastName() {
		return lastName;
	}
	String getAddress() {
		return address;
	}
	String getPhoneNumber() {
		return phoneNumber;
	}
	int getCredits() {
		return credits;
	}
	double getTuition() {
		return tuition;
	}
	double getHealthCare() {
		return healthCare;
	}
	double getLateFee() {
		return lateFee;
	}
	double getMealPlan() {
		return mealPlan;
	}
	String getMealOption() {
		return mealOption;
	}
	String getMealName() {
		String mealName;
		if (getMealOption().equalsIgnoreCase("A"))
			mealName = "Stuff-Your-Face";
		else if (getMealOption().equalsIgnoreCase("B"))
			mealName = "I-Can't-Stand-This-Food";
		else if (getMealOption().equalsIgnoreCase("C"))
			mealName = "I'm-On-A-Diet";
		else
			mealName = "Not specified";
		return mealName;
	}
	double getTotalTuition() {
		return totalTuition;
	}
	double getIncidentalFee() {
		return incidentalFee;
	}
	boolean getState() {
		return state;
	}
	boolean getLateFeeBoolean() {
		return lateFeeBoolean;
	}
	boolean getCampusFood() {
		return campusFood;
	}
	boolean getHealthCareBoolean() {
		return healthCareBoolean;
	}
	
	public void readInput() {
		Scanner sc = new Scanner(System.in);
		
		System.out.print("Enter first name: ");
		setFirstName(sc.next());
		System.out.print("Enter last name: ");
		setLastName(sc.next());
		System.out.print("Enter address: ");
		sc.nextLine();
		setAddress(sc.nextLine());
		System.out.print("Enter phone number: ");
		setPhoneNumber(sc.next());
		System.out.print("Enter the credits you are taken: ");
		setCredits(sc.nextInt());
		System.out.println("Do you qualify for the instate rate? Enter 'true' for yes or 'false' for no");
		setState(sc.nextBoolean());
		System.out.println("Late fee assessed? Enter 'true' for yes or 'false' for no");
		setLateFeeBoolean(sc.nextBoolean());
		System.out.println("Do you want a meal plan? Enter 'true' for yes or 'false' for no");
		setCampusFood(sc.nextBoolean());
		if (getCampusFood() == true) {
			System.out.println("Choose meal option:");
			System.out.println("A: Stuff-Your-Face $ 4999.00\nB: I-Can't-Stand-This-Food $ 3499.00\nC: I'm-On-A-Diet $ 2599.00");
			setMealOption(sc.next());
		}
		System.out.println("Do you want Health Care? Enter 'true' for yes or 'false' for no");
		setHealthCareBoolean(sc.nextBoolean());
	}
	
	public void calculateData() {
		if (getState() == true) {
			if (getCredits() <= 11)
				setTuition(getCredits() * 102.50);
			else if ((getCredits() >= 12) && (getCredits() <= 18))
				setTuition(getCredits() * 75.45);
			else if (getCredits() >= 19)
				setTuition(getCredits() * 93.00);
		} else if (getState() == false) {
			if (getCredits() <= 11)
				setTuition(getCredits() * 351.50);
			else if ((getCredits() >= 12) && (getCredits() <= 18))
				setTuition(getCredits() * 255.00);
			else if (getCredits() >= 19)
				setTuition(getCredits() * 304.00);
		}
		
		if (getLateFeeBoolean() == true)
			setLateFee(getTuition() / 10);
		if (getCampusFood() == true) {
			if (getMealOption().equalsIgnoreCase("A"))
				setMealPlan(4999.00);
			else if (getMealOption().equalsIgnoreCase("B"))
				setMealPlan(3499.00);
			else if (getMealOption().equalsIgnoreCase("C"))
				setMealPlan(2599.00);
		}
		
		if (getHealthCareBoolean() == true) {
			if (getCredits() <= 10)
				setHealthCare(25.00);
			else if (getCredits() >= 11 && getCredits() <= 15)
				setHealthCare(20.00);
			else if (getCredits() >= 16)
				setHealthCare(15.00);
		}
		
		setIncidentalFee(getCredits() * 20);
		setTotalTuition(getTuition() + getLateFee() + getIncidentalFee() + getHealthCare() + getMealPlan());
	}
	
	public void writeOutput() {
		System.out.println("Name: " + getFirstName() + " " + getLastName());
		System.out.println("Address: " + getAddress());
		System.out.println("Phone Number: " + getPhoneNumber());
		System.out.println("Credits: " + getCredits());
		System.out.printf("Tuition: $ %.2f\n", getTuition());
		System.out.printf("Late Fee: $ %.2f\n", getLateFee());
		System.out.printf("Incidental: $ %.2f\n", getIncidentalFee());
		System.out.printf("Health Care: $ %.2f\n", getHealthCare());
		System.out.printf("Meal Plan: %s ($ %.2f)\n", getMealName(), getMealPlan());
		System.out.printf("Total: $ %.2f\n", getTotalTuition());
	}
	
}

This is only for Student class, about the skipping input you can read here for better explanation,
http://blog.ryanrampersad.com/2008/12/19/stop-input-skipping-in-java/

For the meal choice, you can implement it after you prompt whether the user want the meal or not just as I did.

Well, sorry for changing a lot of things cuz it just suit my style. Hope this will help.

Thank you so much! My student class runs great now. I'm having some trouble with my university class though. I get this error:
Exception in thread "main" java.lang.NullPointerException
at University.collectDataForReport(University.java:8)
at Tuition.main(Tuition.java:24)

Thank you so much! My student class runs great now. I'm having some trouble with my university class though. I get this error:
Exception in thread "main" java.lang.NullPointerException
at University.collectDataForReport(University.java:8)
at Tuition.main(Tuition.java:24)

You didn't initialize the Student[] array.

This article has been dead for over six months. Start a new discussion instead.