Answer to Question #234417 in Java | JSP | JSF for Jaden

Question #234417

Create a program where you have to design your own Java console application about any valid problem that your application must solve. Your solution can include solving a business problem, a new idea or even a game. Your application must make use of concepts such as arrays, loops, inheritance, constructors and information hiding. Output must be shown in the form of a report using the console. Use Advanced arrays & Introduction to inheritance


1
Expert's answer
2021-09-07T18:14:43-0400


import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
		StudentResults st = new StudentResults(12, "Isiah", 3);
		st.getSubjects();
		st.displayMarks();
	}
}
class Student{
    private int rollNo;
    private String name;
    public Student(int roll, String n){
        rollNo = roll;
        name = n;
    }
    public void display(){
        System.out.printf("Name: %s\nRoll Number:  %d", name, rollNo);
        
    }
}
class StudentResults extends Student{
    private int[] marks;
    private int number;
    StudentResults(int roll, String n, int s){
       
        super(roll, n);
        number = s;
        marks = new int[number];
        
    }
    void getSubjects(){
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter the three subjects of the student");
        for (int i=0; i<number ; i++ ) {
            System.out.println("Subject: "+ (i+1) );
            marks[i] = scan.nextInt();
        }
    }
        void displayMarks(){
            display();
            System.out.println();
            for (int i=0; i<number ; i++ ) {
            
            System.out.println(marks[i]);
            
        }
        }
    }



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