In this exercise, you have to

In this exercise, you have to calculate the student’s total marks using the concept of Classes
Problem Statement# Write a Java class called Student with
● private fields:
○ name(String type)
○ mark1 and mark2 (double type)
And methods:
● getMarks(int markNumber), a method which should return mark1 if markNumber equals 1 and mark2 otherwise.

● calcTotal() method should take the two marks entered and return their sum. Also define two constructors:
● A default constructor that takes no parameters and initializes the values to zeros and null.
● A constructor that takes the three variables and sets them as the values of the appropriate fields.
Input#
Name of the student and the marks obtained in the first and second tests
Output#
Sum of both marks
Sample Input#
Student student = new Student(“Jack”, 60, 70);
Sample Output# getMarks(1) => 60 getMarks(2) => 70 calcTotal() => 130.0
Part of solution
class Student {

// Define private fields here
public Student() {
// Write definition here
}
public Student(String name, double mark1, double mark2) {
// Write definition here
}
public double getMarks(int markNumber) {
// Write definition here
return 0;
}
public double calcTotal() {
// Write definition here
double totalMarks = 0;
return totalMarks;
}

}
class Demo {
public static void main(String args[]) {
Student student = new Student(“Jack”, 60, 70);
System.out.println(student.calcTotal());
}
}

In this exercise, you have to

In this exercise, you have to create a class called Point which can calculate distance between two points in the x-y plane.
Problem Statement#
You have to implement a class called Point that represents a specific point in the x-y plane. It should contain the following:
● fields:

○ x( integer type)
○ y( integer type) ● methods:
○ default constructor that initializes the point at (0,0)(0, 0)(0,0)
○ parameterized constructor that takes input x and y and initializes the point to the respective coordinates.
○ float distance(), a method which calculates the distance of the point (represented by the object) from the origin, i.e. (0,0)(0, 0)(0,0)
○ float distance(x1, y1), a method which calculates the distance between the point represented by the class object and (x1,y1)(x1, y1)(x1,y1)
Sample Input#
Point p1 = new Point(5, 5);
Sample Output# distance() => 7.071 distance(2, 1) => 5.0
Part of the solution
import java.lang.Math;
class Point {

// Private fields
private int x;
private int y;
// Default Constructor
public Point() {
// Implement the function
}
// Parameterized Constructor
public Point(int x, int y) {
// Implement the function
}
public double distance() {
// Implement the function
return 0;
}

public double distance(int x2, int y2) {
// Implement the function
return 0;
}
}
class Demo {
public static void main(String args[]) {
Point p1 = new Point(5, 5);
System.out.println(p1.distance());
System.out.println(p1.distance(2, 1));
}
}

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more