Answer to Question #227826 in Java | JSP | JSF for Sizo

Question #227826

As a programmer you must be able to follow precise instructions. You will also not always get precise instructions. You must learn to ask questions and make valid deductions of what is expected. Code the StudentAccount class according to the class diagram Methods explanation:  pay(double): double  This method is called when a student pays an amount towards outstanding fees. The balance is reduced by the amount received. The updated balance is returned by the method. addFees(double): double This method is called to increase the balance by the amount received as a parameter.


1
Expert's answer
2021-08-20T13:24:03-0400
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
		StudentAccount s=new StudentAccount();
	}
}
class StudentAccount{
    private String studentName;
    private String studentCourse;
    private double balance;
    public StudentAccount(){
        
    }
    public StudentAccount(String n,String c,double b){
        studentName=n;
        studentCourse=c;
        balance=b;
    }
    public String getStudentName(){
        return studentName;
    }
    public String getStudentCourse(){
        return studentCourse;
    }
    public double getBalance(){
        return balance;
    }
    public void setStudentName(String name){
        studentName=name;
    }
    public void voidsetStudentCourse(String course){
        studentCourse=course;
    }
    public void setBalance(double b){
        balance=b;
    }
    
    public String toString(){
        return "Student name is "+getStudentName()+"\nStudent course is "+getStudentCourse()+"\nBalance= "+getBalance();
    }
    public double pay(double p){
        return (balance-p);
    }
    public double addFees(double a){
        return (balance+a);
    }
    public void refund(){
         double amount;
        Scanner in=new Scanner(System.in);
        amount=in.nextDouble();
        balance=balance-amount;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS