• 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-04-12T10:32:05-0400
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;
Comments
Leave a comment