Answer to Question #319066 in Java | JSP | JSF for jake

Question #319066

Write the code of a class named EXAM with following description. (10 marks)

Private Members;

1. exmCode of type string, 6 characters.

2. exmDescription of type string, 40 characters.

3. noCandidate of type integer.

4. centersReqd (number of centers required) of type integer.

5. A member function CALCNTR( ) to calculate and return the number of

centers as (noCandidates/100+1).

Public Members;

1. A function SCHEDULE( ) to allow user to enter values for exmCode,

xmDescription, noCandidate and call function CALCNTR( ) to calculate the

number of centers.

2. A function DISPXM( ) to allow user to view the content of all the member data.


1
Expert's answer
2022-03-27T17:53:27-0400
import java.io.IOException;
import java.util.Scanner;

public class EXAM {
    private String exmCode;
    private String exmDescription;
    private int noCandidate;
    private int centersReqd;
    private int CALCNTR(){
        this.centersReqd = this.noCandidate / 100 + 1;
        return this.centersReqd;
    }
    public void SCHEDULE(){
        Scanner scanner = new Scanner(System.in);

        System.out.print("Enter Exam Code: ");
        this.exmCode = scanner.nextLine().substring(0,6);

        System.out.print("Enter Exam Description: ");
        this.exmDescription = scanner.nextLine().substring(0,40);

        System.out.print("Enter number of value noCandidate: ");
        this.noCandidate = scanner.nextInt();

        CALCNTR();
    }
    public void DISPXM(){
        System.out.println("\nContent of all the member data\n");
        System.out.println("Code: " + this.exmCode);
        System.out.println("Description: " + this.exmDescription);
        System.out.println("Number of value noCandidate: " + this.noCandidate);
        System.out.println("Number of centers required: " + CALCNTR());
    }

    public static void main(String args[]) throws IOException {
        EXAM exam = new EXAM();
        exam.SCHEDULE();
        exam.DISPXM();
    }
}

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

KG
29.03.22, 13:44

Perfect code

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS