From 2fab97d8be266fae183b5eddfd1e6e56b3aee96f Mon Sep 17 00:00:00 2001 From: giusepped Date: Wed, 30 Jul 2014 00:54:52 +0200 Subject: [PATCH] Create PointsClassReloaded.java --- PointsClassReloaded.java | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 PointsClassReloaded.java diff --git a/PointsClassReloaded.java b/PointsClassReloaded.java new file mode 100644 index 0000000..9114ed9 --- /dev/null +++ b/PointsClassReloaded.java @@ -0,0 +1,56 @@ +import java.util.ArrayList; +/** + * + * @author giuseppedesantis + */ +public class Points { + private ArrayList points; + int accepted; + int zeros; + + public Points(ArrayList gradesInString){ + this.points = new ArrayList(); + for(String g : gradesInString){ + int points = Integer.parseInt(g); + if (points >= 0 && points <= 29){ + this.points.add(0); + this.zeros++; + }else if (points <= 34 && points >= 30){ + this.points.add(1); + this.accepted++; + }else if (points <= 39 && points >= 35){ + this.points.add(2); + this.accepted++; + }else if (points <= 44 && points >= 40){ + this.points.add(3); + this.accepted++; + }else if (points <= 49 && points >= 45){ + this.points.add(4); + this.accepted++; + }else if (points <= 60 && points >= 50){ + this.points.add(5); + this.accepted++; + } + } + } + + public void pointsStats(){ + System.out.println("Grade distribution:"); + for(int i = 5; i >= 0; i--){ + System.out.print(i+": "); + for(int points : this.points){ + if(points == i){ + System.out.print("*"); + } + } + System.out.println(""); + } + } + + public void acceptancePercentage(){ + double allScores = (double)(this.accepted + this.zeros); + double accepted = (double)(this.accepted); + double acceptancePercentage = 100*accepted/allScores; + System.out.println("Acceptance percentage: "+ acceptancePercentage); + } +}