62 478
Assignments Done
98,8%
Successfully Done
In June 2018

Answer to Question #66556 in Java | JSP | JSF for acap

Question #66556
MSU Holding Sdn Bhd hires a programmer to create an application to calculate their student fee using class and object method.

class student
{
private String name;
private String student_ID;
private double num_of_subject;
}

• Create a class named student. Add new data fields that are String name, String student_ID and double num_of_subject. This class will store the information from the main class using set and get method.

• Create a class named Fee. This class will calculate the fees for a particular student. The fee for per subject is RM250. The calculation is fee = num_of_subject x 250.

• Create a main class which will ask the user to enter the following data: student Name, student ID and number of subject taken for particular semester using Scanner technique. This program must be able to display back all the data entered by the user and student fee.
Expert's answer
import java.util.Scanner;


public class Main {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.println("Enter name, student_ID, and number of subjects:");
String name = sc.next();
String id = sc.next();
double numberOfSubjects = sc.nextDouble();
Student s = new Student(name,id,numberOfSubjects);
System.out.println("Student's name: "+s.getName()+"\nStudent's id: "+s.getStudent_ID()+"\nStudent's number of subjects: "+
s.getNum_of_subject()+"\nStudent's fee: "+Fee.fee(s));
}
}


public class Student {
private String name;
private String student_ID;
private double num_of_subject;

public Student(String name, String student_ID, double num_of_subject) {
this.name = name;
this.student_ID = student_ID;
this.num_of_subject = num_of_subject;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getStudent_ID() {
return student_ID;
}

public void setStudent_ID(String student_ID) {
this.student_ID = student_ID;
}

public double getNum_of_subject() {
return num_of_subject;
}

public void setNum_of_subject(double num_of_subject) {
this.num_of_subject = num_of_subject;
}
}


public class Fee {
private static final double fee = 250;
public static double fee(Student s){
return s.getNum_of_subject() * fee;

}
}

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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions