Skip to content

Commit

Permalink
10/13
Browse files Browse the repository at this point in the history
  • Loading branch information
Ardusa committed Oct 13, 2023
1 parent 051d550 commit 5b05b25
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Balloon.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
public class Balloon {
private double radius;

public Balloon() {
radius = 0;
}

public void inflate(double amount) {
radius += amount;
}

public double getVolume() {
return 4.0 / 3.0 * Math.PI * Math.pow(radius, 3);
}


public static void main(String... args) {
Balloon balloon = new Balloon();
balloon.inflate(10);
System.out.println("Balloon volume: " + balloon.getVolume());
}
}

28 changes: 28 additions & 0 deletions Student.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
public class Student {
private String name;
private int totalQuizScore;
private int numberOfQuizzes;

public Student(String name) {
this.name = name;
this.totalQuizScore = 0;
this.numberOfQuizzes = 0;
}

public String getName() {
return name;
}

public void addQuiz(int score) {
totalQuizScore += score;
numberOfQuizzes++;
}

public int getTotalScore() {
return totalQuizScore;
}

public int getAverageScore() {
return totalQuizScore / numberOfQuizzes;
}
}
11 changes: 11 additions & 0 deletions StudentTester.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public class StudentTester {
public static void main(String... args) {
Student student = new Student("John Doe");
student.addQuiz(10);
student.addQuiz(20);
student.addQuiz(30);
System.out.println("Student name: " + student.getName());
System.out.println("Student total score: " + student.getTotalScore());
System.out.println("Student average score: " + student.getAverageScore());
}
}

0 comments on commit 5b05b25

Please sign in to comment.