Results 1 to 2 of 2
- 10-01-2009, 10:47 PM #1
Member
- Join Date
- Oct 2009
- Posts
- 6
- Rep Power
- 0
Help with implement class programming assignment
I need to store the number of quizzes taken so that the program will compute the average score. This is what I have:
public class Student {
private double totalscore;
private String studentName;
private double average;
public Student(){
totalscore = 0;
average = totalscore/3;
}
public Student (String name){
studentName = name;
}
public void addQuiz(int score){
totalscore = totalscore + score;
}
public void AverageScore(){
average = totalscore/3;
}
public double getAverageScore(){
return average;
}
public double getTotalScore(){
return totalscore;
}
public String getName(){
return studentName;
}
(this is the Student Class)
public class StudentTester {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Student Amanda = new Student("Amanda Hunter");
Amanda.addQuiz(90);
Amanda.addQuiz(95);
Amanda.addQuiz(87);
Amanda.getTotalScore();
Amanda.getName();
Amanda.getAverageScore();
System.out.println(Amanda.getName());
System.out.println(Amanda.getTotalScore());
System.out.println(Amanda.getAverageScore());
System.out.println();
Student Brian = new Student("Brian Wyman");
Brian.addQuiz(100);
Brian.addQuiz(90);
Brian.addQuiz(97);
Brian.getTotalScore();
Brian.getName();
Brian.getAverageScore();
System.out.println(Brian.getName());
System.out.println(Brian.getTotalScore());
System.out.println(Brian.getAverageScore());
System.out.println();
Student Ben = new Student("Ben Hunter");
Ben.addQuiz(85);
Ben.addQuiz(96);
Ben.addQuiz(92);
Ben.getTotalScore();
Ben.getName();
Ben.getAverageScore();
System.out.println(Ben.getName());
System.out.println(Ben.getTotalScore());
System.out.println(Ben.getAverageScore());
System.out.println();
}
(this is the StudentTester Class)
-
This is a duplicate or Cross-post and thus will be locked.
Crosspost: need help with implementing class
OP, please choose the one single best forum to post your question so as not to divide the discussion. If you have any cross-posts of this same question in other fora, you should also post the links here. Thank you for your cooperation.
Similar Threads
-
E:\IT 215 Java Programming\GUI1.java:125: class, interface, or enum expected
By tlouvierre in forum New To JavaReplies: 1Last Post: 05-31-2009, 10:57 PM -
E:\IT 215 Java Programming\GUI1.java:125: class, interface, or enum expected
By tlouvierre in forum New To JavaReplies: 1Last Post: 05-31-2009, 02:17 PM -
E:\IT 215 Java Programming\Inventory.java:36: class, interface, or enum expected
By tlouvierre in forum Advanced JavaReplies: 16Last Post: 05-28-2009, 03:41 PM -
E:\IT 215 Java Programming\public class Inventory.java:39: class, interface, or enum
By tlouvierre in forum New To JavaReplies: 14Last Post: 05-28-2009, 05:44 AM -
Implement a class Employee-Help due tmrw!
By Britt7 in forum New To JavaReplies: 3Last Post: 10-27-2008, 01:37 AM


LinkBack URL
About LinkBacks

Bookmarks