Answer to Question #66362 in Java | JSP | JSF for botnet

Question #66362
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.
1
Expert's answer
2017-03-21T02:35:06-0400
// Fee.java
public class Fee {

double calc(double num_of_sub)
{
return num_of_sub*250;
}
}

// Student.java

public class Student {
private String name="Incognito";
private String student_ID="******";
private double num_of_subject=0;
private Fee f=new Fee();


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 toString()
{
return "Student "+name+"|| Student Id: "+student_ID+
"|| Number of subject: "+num_of_subject+". Student fee: "+f.calc(num_of_subject)+".";
}
}



// Main.java
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String name;
String student_id;
double num_of_subject;
while (true) {
System.out.println("Enter name of student");
name = in.next();
System.out.println("Enter id of student");
student_id = in.next();
System.out.println("Enter number of subject");
num_of_subject = in.nextInt();
Student student = new Student(name, student_id, num_of_subject);

System.out.println("To see information of student - enter '1'");
System.out.println("Continue - enter '0'");
int enter = in.nextInt();

switch (enter) {
case 1:
System.out.println(student.toString());
break;
default:
break;
}
}

}

}

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
APPROVED BY CLIENTS