Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7407051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:39:00+00:00 2026-05-29T05:39:00+00:00

Apologies for vague title as i couldn’t think what the name is. Basically creating

  • 0

Apologies for vague title as i couldn’t think what the name is.

Basically creating a small program that calculates a students financial payment.
When i run it, it calculates the object allowance no problem.
However whatever i try the object ‘Bursary’ doesn’t seem to come up with anything aside 0.

The code is as follows :

import java.util.Scanner;

public class studentFinance implements Payment {
    private String stuname, department, course;
    private float budget, allowance, bursary;
    private int id, currentbudget, attendance;
    private double numbofcourses;

    // student name, id, department, course enrolledon, attendance, bursary,allowance

    //course and numbofcourses already read in
    Scanner in = new Scanner(System.in);

    public studentFinance(float currentBudget) {
        budget = currentbudget;
    }

    public float amendBudget(float newbudget) {
        budget = newbudget;//Transfer data from parameter to instance variable
        return budget;//Return statement
    }

    public float calcPayment() {
        //stuname,department,numbofcourses,attendance,id

        System.out.println("Please enter the student name");
        stuname = in.next();
        System.out.println("Please enter the department name");
        department = in.next();
        System.out.println("Please enter the number of numbofcourses");
        numbofcourses = in.nextDouble();
        System.out.println("Please enter the attendance");
        attendance = in.nextInt();
        System.out.println("Please enter their ID number");
        id = in.nextInt();
        System.out.println("Enter HND,HNC or NC");
        course = in.next();

        if (attendance > 95 & numbofcourses >= 6) {
            allowance = 1000;
        } else if (attendance > 85 & numbofcourses >5) {
            allowance = (1000 * .75F);
        } else if (attendance > 75 & numbofcourses >= 4) {
            allowance = (1000 * .5F);
        } else if (attendance > 75 & numbofcourses >= 3) {
            allowance = 100;
        } else {
            allowance = 0;
        }

        if(course=="HND") {
            bursary = 250;
        } else if(course=="HNC") {
            bursary = 200;
        } else if(course=="NC") {
            bursary = 100;
        } else {
            bursary = 0;
        }

        return bursary + allowance;
    } 

    double payment;

    public void makePayment() {
        System.out.println("The allowance total is : " + payment);
        payment = bursuary + allowance;
    }

    public void print() {

    }


}

If it isany use this is the code used for the interface , theirs other elements to it but i don’t think they are relevant here.

interface Payment {
    public float amendBudget(float budget);
    public float calcPayment();
    public void  makePayment();
    public void  print();
}

Regards for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:39:02+00:00Added an answer on May 29, 2026 at 5:39 am

    == doesn’t do what you think it does here. == (when applied to objects) just checks to see if two objects are the same object, not if their contents are equivalent, so it doesn’t work for strings here. What you want is:

    if("HND".equals(course)) {
      // ...
    } else if ("HNC".equals(course)) {
      // ...
    } // etc
    

    Generally you only want to use == when dealing with primitives (int, float, etc), or you explicitly just want to see if two variables point to exactly the same object.

    You could also write them as:

    if(course.equals("HND")) {}
    

    but I prefer to use .equals on the constants as you know they will never be null. It’s probably not a concern for you here, but it’s just the pattern I’ve gotten used to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that the title was very vague and my apologies. I am using
Couldn't seem to think of a good title, my apologies. Feel free to change
Firstly, apologies for the vague title, but I'm not sure exactly what I'm asking
I apologize for the vague title. I am attempting to write a query that
I apologize for the Title of this Question, but I couldn't think of a
Apologies if this is a bit vague, but that's half of the problem. I
Apologies for the vague title, it's kind of hard to explain in a line...
I apologize for the vague title, but I can't think of a better way
Apologies for the vague title, here's my problem: The goal of my code is
Apologies for the vague question. Here it is: I have a table object created

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.