-4

With help I got the program to run and answer the questions but it does not show the tuition total.

import java.util.Scanner;

public class Student {

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

    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()
    {   
    }
    public static void main(String[] args) {
        sc = new Scanner(System.in);
        System.out.println("Enter first name");
        FirstName=sc.nextLine();
        System.out.println("Enter last name");
        LastName=sc.nextLine();
        System.out.println("Enter address");
        Address=sc.nextLine();
        System.out.println("Enter phone number");
        PhoneNumber=sc.nextLine();
        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);
        calculateData();
        writeOutput();
    }
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
David
  • 1
  • 1
  • 5
  • The errors are completely correct. `Java Syntax (Toggle Plain Text)` is not valid code. – SLaks May 13 '15 at 16:14
  • I just formatted your code. Finding where to put the `}` should be a bit more obvious now. – But I'm Not A Wrapper Class May 13 '15 at 16:42
  • I copied the code and I still get the error, could you let me know where you put it? – David May 13 '15 at 16:50
  • If you formatted your code correctly (or at all) you would have easily found this error yourself. Try searching for "Java Code Formatting Standards", or something of the sort. Also, using some sort of IDE (IntelliJ is a good choice) would even do your formatting for you. – Hypino May 13 '15 at 17:55

2 Answers2

0

remove below line from your code and you are done.

public static void main(String[] args) {
prashant thakre
  • 5,061
  • 3
  • 26
  • 39
  • That fixes the error but I need to get user input and I can't run the program without public static void main(String[] args) { – David May 13 '15 at 17:02
  • @David you need to read Java Tutorials as your code having many methods and not good coding, Its difficult here to explain. – prashant thakre May 13 '15 at 17:07
0

Your main method located at the top of your class:

public static void main(String[] args) {

Is never closed, you should do something like this:

public static void main(String[] args) {

}

Now your error should be resolved but without something inside your main method your code will probably not work unless ofcourse you are calling methods from this class from another class.

But if this main method is the only main method in your project then none of the other code you wrote will every be used. As youe main method is the method that will call other methods an thus makes your code do something.

I hope this helps :)

EDIT #1:

When I tried to properly format your code I noticed that the main method is not the only method that has an issue with brackets the last two (or three) methods also have severe problems with brackets. So I'd recomend that you check those methods aswel or I could try to do it but it would be easier if you did that yourself.

EDIT #2:

In response of edit #1 I have now fixed al the problems there where with the brackets { and }.

The 'new' code:

import java.util.Scanner;

public class Student {

public static void main(String[] args) {
    //add the code for what you want to do in here
}

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);
}
}

EDIT #3

Added the fully functional code:

package stackoverflow.q30220193;

import java.util.Scanner;

public class Student {

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

public static void main(String[] args) {
    sc = new Scanner(System.in);
    System.out.println("Enter first name");
    FirstName=sc.nextLine();
    System.out.println("Enter last name");
    LastName=sc.nextLine();
    System.out.println("Enter address");
    Address=sc.nextLine();
    System.out.println("Enter phone number");
    PhoneNumber=sc.nextLine();
    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();
    calculateData();
    writeOutput();
}

public static 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 static 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);
}
}

P.S. I removed the gettes and setters but you can add them back in if you want to.

Roan
  • 1,200
  • 2
  • 19
  • 32