Question

Write the definition of the class Tests such that an object of this class can store...

Write the definition of the class Tests such that an object of this class can store a student's first name, last name, five test scores, average test score, and grade. (Use an array to store the test scores.) Add constructors and methods to manipulate data stored in an object. Among other things, your class must contain methods to calculate test averages, return test averages, calculate grades, return grades, and modify individual test scores. The method toString must return test data (including student's name, five test scores, average, and grade) as a string. Write a program to calculate student's average test scores and the grade. You may assume the following in put data: Read these from a file Jack Johnson 85 83 77 91 76 Lisa Aniston 80 90 95 93 48 Andy Cooper 78 81 11 90 73 Ravi Gupta 92 83 30 69 87 Bonny Blair 23 45 96 38 59 Danny Clark 60 85 45 39 67 Samantha Kennedy 77 31 52 74 83 Robin Bronson 93 94 89 77 97 Sheila Sunny 79 85 28 93 82 Kiran Smith 85 72 49 75 63 It will be saved as Tests.java. Make sure to have the following in this class: a. Constructor for first name, last name, five tests scores (an array), average tests score and grade. b. Method to calculate the average c. Method to calculate the letter grade d. Set and Get methods for the names, and tests e. Get Grade method Java Programming: From Problem Analysis to Program Design 9-2 f. Get Average method g. toString method -Create another .java file to test the class. a. Use the data file I provided. b. Output to the screen not an output file. c. Take a screen shot of your output. d. Your book shows how the output should look

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

if you have any doubts, please give me comment...

import java.util.*;

import java.io.*;

public class TestsDemo {

public static void main(String[] args) {

Scanner userIn = new Scanner(System.in);

Tests[] tests = new Tests[10];

String fname, lname;

int scores[];

int n = 0;

for (int i = 0; i < 10; i++) {

fname = userIn.next();

lname = userIn.next();

scores = new int[5];

for (int j = 0; j < 5; j++)

scores[j] = userIn.nextInt();

tests[n] = new Tests(fname, lname, scores);

n++;

}

System.out.printf("%-10s %-10s %5s %5s %5s %5s %5s %8s %8s\n", "First Name", "Last Name", "Test1", "Test2",

"Test3", "Test4", "Test5", "Average", "Grade");

for (int i = 0; i < n; i++) {

System.out.println(tests[i].toString());

}

}

}

Add a comment
Know the answer?
Add Answer to:
Write the definition of the class Tests such that an object of this class can store...
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
  • this is a java course class. Please, I need full an accurate answer. Labeled steps of...

    this is a java course class. Please, I need full an accurate answer. Labeled steps of the solution that comply in addition to the question's parts {A and B}, also comply with: (Create another file to test the class and output to the screen, not an output file) please, DO NOT COPY others' solutions. I need a real worked answer that works when I try it on my computer. Thanks in advance. Write the definition of the class Tests such...

  • Could someone show how to do this in C#? I keep getting errors for mine and...

    Could someone show how to do this in C#? I keep getting errors for mine and the other answers on here that are similar doesn't work. And please make sure it accepts user input. Write the class "Tests". Ensure that it stores a student's first name, last name, all five test scores, the average of those 5 tests' scores and their final letter grade. (Use an array to store test scores.) Add constructors and methods to manipulate the data stored...

  • Write a program to calculate students’ average test scores and their grades. You may assume the...

    Write a program to calculate students’ average test scores and their grades. You may assume the following data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three...

  • Write a program to calculate students’ average test scores and their grades. You may assume the...

    Write a program to calculate students’ average test scores and their grades. You may assume the following data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three...

  • Student average array program

    Having a bit of trouble in my c++ class, was wondering if anyone can help.Write a program to calculate students' average test scores and their grades. You may assume the following input data:Johnson 85 83 77 91 76Aniston 80 90 95 93 48Cooper 78 81 11 90 73Gupta 92 83 30 68 87Blair 23 45 96 38 59Clark 60 85 45 39 67Kennedy 77 31 52 74 83Bronson 93 94 89 77 97Sunny 79 85 28 93 82Smith 85 72...

  • Write a Java program that reads a file until the end of the file is encountered....

    Write a Java program that reads a file until the end of the file is encountered. The file consists of an unknown number of students' last names and their corresponding test scores. The scores should be integer values and be within the range of 0 to 100. The first line of the file is the number of tests taken by each student. You may assume the data on the file is valid. The program should display the student's name, average...

  • use  JOptionPane to display output Can someone please help write a program in Java using loops, not...

    use  JOptionPane to display output Can someone please help write a program in Java using loops, not HashMap Test 1 Grades After the class complete the first exam, I saved all of the grades in a text file called test1.txt. Your job is to do some analysis on the grades for me. Input: There will not be any input for this program. This is called a batch program because there will be no user interaction other than to run the program....

  • C++: Create a grade book program that includes a class of up to 20 students each...

    C++: Create a grade book program that includes a class of up to 20 students each with 5 test grades (4 tests plus a Final). The sample gradebook input file (CSCI1306.txt) is attached. The students’ grades should be kept in an array. Once all students and their test scores are read in, calculate each student’s average (4 tests plus Final counts double) and letter grade for the class. The output of this program is a tabular grade report that is...

  • IN JAVA Write a class Store which includes the attributes: store name, city. Write another class...

    IN JAVA Write a class Store which includes the attributes: store name, city. Write another class encapsulating an Art Gallery, which inherits from Store. An Art Gallery has the following additional attributes: how many paintings are sold every year and the number of artists submitting artwork. Code the constructor, accessors, mutators, toString and equals method of the super class Store. Code the constructor, accessors and mutators for the subclass Art Gallery. In the Art Gallery class, also code a method...

  • 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...

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