+ 1
Help me please
can anyone help me to clear it... some silly errors but I can't figure it out... please help me to rectify my errors https://code.sololearn.com/cMybYp50Um1x/?ref=app
3 Answers
+ 5
Just correct the syntax and you should be good! Do this line by line for all 23 errors. They are not major ones.
+ 2
thank you Chaotic Dawng ,can you write calling part for me
+ 1
This may be closer to what you're looking for. P.S. readline() from DataInputStream is deprecated.
Look through the code carefully and compare the differences including syntax, spelling and class placement etc. You had too many errors to comment on in just this post.
package student;
import java.util.Scanner;
import java.io.IOException;
public class InheritanceExamples {
public static void main(String args[]) throws IOException {
Result result = new Result();
result.getData();
result.getMarks();
result.putData();
result.putMarks();
result.display();
}
}
class Student {
private int rollNo;
private String name;
void getData() throws IOException {
Scanner sc = new Scanner(System.in);
System.out.print("Enter rollNo: ");
rollNo = Integer.parseInt(sc.nextLine());
System.out.print("Enter the name: ");
name = sc.nextLine();
}
void putData() {
System.out.println("rollNo: " + rollNo);
System.out.println("name: " + name);
}
}
class Mark extends Student {
int mark1, mark2, total;
void getMarks() throws IOException {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the mark1: ");
mark1 = Integer.parseInt(sc.nextLine());
System.out.print("Enter the mark2: ");
mark2 = Integer.parseInt(sc.nextLine());
}
void putMarks() {
System.out.println("mark1: " + mark1);
System.out.println("mark2: " + mark2);
}
}
interface Sports {
int sports = 5;
void display();
}
class Result extends Mark implements Sports {
public void display() {
System.out.println("sports: " + sports);
total = mark1 + mark2 + sports;
System.out.println("total: "+ total);
}
}