Question

Assignment W3-2 This programming assignment addresses: •Compiling and Executing an App with more than 1 class...

Assignment W3-2

This programming assignment addresses:

•Compiling and Executing an App with more than 1 class

•Initializing Objects using Constructors

•Software Engineering with Private Instances Variables and Public Set/Get Methods

•Uses Methods inside classes

Description: You are asked to write a program to process two students’ scores. Each student will have scores for 3 tests, the user will input each student’s full name followed by their three scores. When the data for the two students are read from the keyboard, your program should output the following reports:

•For each student, you should output their highest as well as the average score.

•You should output the full name of the student who has the highest average score.

•Your program should output the name(s) of the students who qualify for the assistant ship.

For a student to qualify for an assistantship, they must have at least one grade of A (that is a score in the range of 90-100.

Important note: if there is no qualifying student, your report simply does not mention any names.

The following is the requirements of this program:

•Declare a class called Student whose attributes should be their full name and 3 scores(Do not use an array).

•Define a constructor for class Student that will be used to initialize their full name and the three scores (all int), should not accept parameters, which means you have to specify null initial values to all attributes.

•You MUST have the following methods as part of your Student class:

All the proper set and get methods.

A method that computes the average of the three scores.

A method that computes the highest of the three scores.

A method that outputs a proper message only if the student is qualified for the assistantship.

•Two files:Class Student (Student.java) and Main program to test the class(Main.java)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Student.java

//declare Student class
class Student
{
//instance variables
String fullName;
int score1,score2,score3;
//constructor
public Student()
{
    fullName=null;
    score1=0;
    score2=0;
    score3=0;
}
//set & get methods for instance variables
public void setFullName(String fullName)
{
    this.fullName=fullName;
}
public String getFullName()
{
    return this.fullName;
}
public void setScore1(int score1)
{
    this.score1=score1;
}
public int getScore1()
{
    return this.score1;
}
public void setScore2(int score2)
{
    this.score2=score2;
}
public int getScore2()
{
    return this.score2;
}
public void setScore3(int score3)
{
    this.score3=score3;
}
public int getScore3()
{
    return this.score3;
}
//compute average score
public double averageScore()
{
    return (score1+score2+score3)/3.0;
}
//maximum score
public int maximumScore()
{
    if(score1>score2 && score1>score3)
    return score1;
    else if(score2>score3)
    return score2;
    else
    return score3;
}
//check qualified for assistantship or not
boolean checkQualifiedForAssistantship()
{
     if((score1>=90 && score1<=100) || (score2>=90 && score2<=100) || (score3>=90 && score3<=100))
     return true;
     else
     return false;
}
}

Main.java

import java.util.Scanner; //reads data from inputstream
class Main
{
public static void main(String[] args)
{
     //declare Scanner object
     Scanner input=new Scanner(System.in);
     //declare two Student objects
     Student student1=new Student();
     Student student2=new Student();
     System.out.println("Enter Student1 details");
     System.out.println("Enter full name");
     student1.setFullName(input.nextLine());
     System.out.println("Enter score1");
     student1.setScore1(input.nextInt());
     System.out.println("Enter score2");
     student1.setScore2(input.nextInt());
     System.out.println("Enter score3");
     student1.setScore3(input.nextInt());
     input.nextLine();
     System.out.println("Enter Student2 details");
     System.out.println("Enter full name");
     student2.setFullName(input.nextLine());
     System.out.println("Enter score1");
     student2.setScore1(input.nextInt());
     System.out.println("Enter score2");
     student2.setScore2(input.nextInt());
     System.out.println("Enter score3");
     student2.setScore3(input.nextInt());
     if(student1.checkQualifiedForAssistantship()==true)
     {
        System.out.println("Student1 qualified for Assistantship");
        System.out.println("Full Name "+student1.getFullName());
        System.out.println("Score1 "+student1.getScore1());
        System.out.println("Score2 "+student1.getScore2());
        System.out.println("Score3 "+student1.getScore3());
        System.out.println("Average Score "+student1.averageScore());
        System.out.println("Maximum Score "+student1.maximumScore());
     }
     else
     System.out.println("Student1 not qualified for Assistantship");
     if(student2.checkQualifiedForAssistantship()==true)
     {
        System.out.println("Student2 qualified for Assistantship");
        System.out.println("Full Name "+student2.getFullName());
        System.out.println("Score1 "+student2.getScore1());
        System.out.println("Score2 "+student2.getScore2());
        System.out.println("Score3 "+student2.getScore3());
        System.out.println("Average Score "+student2.averageScore());
        System.out.println("Maximum Score "+student2.maximumScore());
     }
     else
     System.out.println("Student1 not qualified for Assistantship");
}
}

Output

Add a comment
Know the answer?
Add Answer to:
Assignment W3-2 This programming assignment addresses: •Compiling and Executing an App with more than 1 class...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • please help asap in c++, you dont have to do everything but at least give me...

    please help asap in c++, you dont have to do everything but at least give me a starting idea of how this should look like Write a class Assignment that has private attributes for Name, Possible Points and Earned Points Write a class Student that has private attributes for name and a vector of assignments. The constructor method should require a name. Add a method for get total score that returns the total number of points earned divided by the...

  • [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and...

    [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and methods must be used for this program. Process: •Read the number of students in a class. Make sure that the user enters 1 or more students. •Create an array with the number of students entered by the user. •Then, read the name and the test score for each student. •Calculate the best or highest score. •Then, Calculate letter grades based on the following criteria:...

  • Within DrJava, create a class called StudentQuizScores and do the following using a do-while loop. 1....

    Within DrJava, create a class called StudentQuizScores and do the following using a do-while loop. 1. You program will read in a student’s first name. The same will be done for the student’s last name. Your program will use respective methods (described below) to accomplish this. 2. Your program will then read in three quiz scores, respectively. This should be done by using the same method three times. This method is described below. 3. Your program will then calculate the...

  • THIS IS FINAL COURSE ASSIGNMENT, PLEASE FOLLOW ALL REQUIREMENTS. Hello, please help write program in JAVA...

    THIS IS FINAL COURSE ASSIGNMENT, PLEASE FOLLOW ALL REQUIREMENTS. Hello, please help write program in JAVA that reads students’ names followed by their test scores from "data.txt" file. The program should output "out.txt" file where each student’s name is followed by the test scores and the relevant grade, also find and print the highest test score and the name of the students having the highest test score. Student data should be stored in an instance of class variable of type...

  • Java Program: In this project, you will write a program called GradeCalculator that will calculate the...

    Java Program: In this project, you will write a program called GradeCalculator that will calculate the grading statistics of a desired number of students. Your program should start out by prompting the user to enter the number of students in the classroom and the number of exam scores. Your program then prompts for each student’s name and the scores for each exam. The exam scores should be entered as a sequence of numbers separated by blank space. Your program will...

  • java This lab is intended to give you practice creating a class with a constructor method,...

    java This lab is intended to give you practice creating a class with a constructor method, accessor methods, mutator methods, equals method , toString method and a equals method. In this lab you need to create two separate classes, one Student class and other Lab10 class. You need to define your instance variables, accessor methods, mutator methods, constructor, toString method and equals method in Student class. You need to create objects in Lab10 class which will have your main method...

  • Your assignment is to write a grade book for a teacher. The teacher has a text file, which includ...

    Your assignment is to write a grade book for a teacher. The teacher has a text file, which includes student's names, and students test grades. There are four test scores for each student. Here is an example of such a file: Count: 5 Sally 78.0 84.0 79.0 86.0 Rachel 68.0 76.0 87.0 76.0 Melba 87.0 78.0 98.0 88.0 Grace 76.0 67.0 89.0 0.0 Lisa 68.0 76.0 65.0 87.0 The first line of the file will indicate the number of students...

  • please use java do what u can 1. Modify the Student class presented to you as...

    please use java do what u can 1. Modify the Student class presented to you as follows. Each student object should also contain the scores for three tests. Provide a constructor that sets all instance values based on parameter values. Overload the constructor such that each test score is assumed to be initially zero. Provide a method called set Test Score that accepts two parameters: the test number (1 through 3) and the score. Also provide a method called get...

  • need the raptor flowchart with extra credit part made with procedures/ parameters. will give thumbs up...

    need the raptor flowchart with extra credit part made with procedures/ parameters. will give thumbs up Quiz Statistics For this assignment, you will write a program that requests the quiz scores for 6 students Identified by ID numbers. The program computes the average score and determines the ID number of the student with the highest score. Not an input, should be in The ID numbers for the students in this class are: 1234 2333 4432 3323 2143 3425 (program This...

  • Write a program that performs the following: 1. Presents the user a menu where they choose...

    Write a program that performs the following: 1. Presents the user a menu where they choose between:              a. Add a new student to the class                           i. Prompts for first name, last name                           ii. If assignments already exist, ask user for new student’s scores to assignments              b. Assign grades for a new assignment                           i. If students already exist, prompt user with student name, ask them for score                           ii. Students created after assignment will need to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT