Answer to Question #227236 in Java | JSP | JSF for Chadwin Fritz

Question #227236

StudentAccount

      

     -studentName: String

     -studentCourse: String

     -balance: double

      

     +StudentAccount()

     +StudentAccount(String,String,double)

     +getters()

     +setters()

     +toString(): String

     +pay(double): double

     +addFees(double): double

     +refund(): void



Code the StudentAccount class according to the class diagram


1
Expert's answer
2021-08-18T11:20:35-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