1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
r-ruslan [8.4K]
3 years ago
6

Write a class called Course that represents a course taken at a school. Represent each student using the modified Student class

from the previous programming project. Use an ArrayList in the Course to store the students taking that course. The constructor of the Course class should accept only the name of the course. Provide a method called addStudent that accepts one Student parameter. Provide a method called average that computes and returns the average of all students’ test score averages. Provide a method called roll that prints all students in the course. Create a driver class with a main method that creates a course, adds several students, prints a roll, and prints the overall course test average.
Computers and Technology
1 answer:
Vinvika [58]3 years ago
3 0

Answer:

The code is given below with its appropriate output

Explanation:

//Student.java

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;

import java.util.Scanner;

public class Student {

public String firstName;

public String lastName;

public float[] marks;

Scanner scanner = new Scanner(System.in);

public Student(String firstName, String lastName) {

this.firstName = firstName;

this.lastName = lastName;

}

public void getdetail() {

System.out.println("enter only five marks");

marks = new float[5];

int count = 0;

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

float mark = 0;

++count;

if (count <= 5) {

System.out.println("enter score " + count);

mark = scanner.nextFloat();

if (mark >= 0.0 && mark <= 100.0)

marks[i] = mark;

else {

System.out.println("you entered mark is invalid");

marks[i] = 0;

}

} else

System.out.println(" maximum is five only");

}

}

public void tostring() {

System.out.println("firstname :" + "\t" + firstName + "\t" + "lastname :"

+ "\t" + lastName + "\n" + "the marks are");

int count = 0;

for (float mark : marks) {

count++;

System.out.println("the mark of " + count + " is " + mark);

}

}

public void Averagecal() {

float sum = 0.0f;

for (float mark : marks) {

sum = sum + mark;

}

float avg = sum / 5;

System.out.println("average of a student is " + avg);

}

}

//Course.java

import java.io.*;

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;

import java.util.Scanner;

public class Course {

public String courseName;

public int number;

Student[] students;

Scanner scanner = new Scanner(System.in);

public Course(String courseName) {

this.courseName = courseName;

}

public void addStudents() {

System.out

.println("how many no of students you want to add for this particular course");

int count = scanner.nextInt();

students = new Student[count];

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

System.out.println("enter the first name");

String fname = scanner.next();

System.out.println("enter the last name");

String lname = scanner.next();

Student s = new Student(fname, lname);

s.getdetail();

s.tostring();

s.Averagecal();

students[i] = s;

}

}

public void roll() {

int count = 0;

for (Student stud : students) {

count++;

}

System.out.println("the no of students in this " + courseName

+ " course is " + count);

}

}

//Driver.java

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;

import java.util.Scanner;

public class Driver {

public static void main(String[] args) {

Course course = new Course("java");

course.addStudents();

course.roll();

}

}

<u>output: </u>

C:\Users\Daniel\Desktop\New folder>javac Student.java

C:\Users\Danie;\Desktop\New folder>javac Course.java

C:\Users\Daniel\Desktop\New folder>javac Driver.java

C:\Users\Daniel\Desktop\New folder>java Driver

how many no of students you want to add for this particular course ?

1

enter the first name

john

enter the last name

rich

enter only five marks

enter score 1

89

enter score 2

91

enter score 3

85

enter score 4

78

enter score 5

96

firstname : john lastname : rich

the marks are

the mark of 1 is 89.0

the mark of 2 is 91.0

the mark of 3 is 85.0

the mark of 4 is 78.0

the mark of 5 is 96.0

average of a student is 87.8

the no of students in this java course is 1

C:\Users\Ravi\Desktop\New folder>

You might be interested in
Ransomware as a service has allowed the increase of:.
Montano1993 [528]

Ransomware as a Service has allowed the increase of ransomware infections globally.

<h3>What is a Ransomware as a Service?</h3>

Ransomware as a Service is a type of business association between ransomware operators and affiliates. These affiliates pay to launch ransomware attacks developed by operators.

A ransomware is a type of malicious software that infects the computer of an organization thereby restricting access to their important data unless an amount of money is paid.

Ransomware as a Service has allowed the increase of ransomware infections globally because this business model has allowed malware creators to earn from their ransomware by enlisting a network of distributors.

Therefore, ransomware as a service has allowed the increase of ransomware infections globally.

Learn more about ransomware here:

brainly.com/question/23294592

6 0
2 years ago
Can somebody plz explain this question to me?
viktelen [127]
11 30 21 would be the output.
5 0
3 years ago
What should a good interface delight incorporate?
antoniya [11.8K]

<u>Answer:</u>  

A) a very long but detailed menu system

<u>Explanation:</u>

A <em>detailed menu will never attract or support the user in any form</em>. It might be difficult to use the application for longer time due to the <em>un supportive menu format.</em>

Option B: This option might look closer to the answer but it might not attract if many users are unaware of the latest changes.

Option C: The application should support and should not challenge the user. It is not a quiz or game show to challenge people.

Option D: Any GUI should be attractive so that the user tend to use it frequently.

8 0
2 years ago
How should the two heats of reaction for the neutralization of naoh and the two acids compare?
Mars2501 [29]

NaOH is a strong base so strength of acid is not important.  The two heats of neutralisation per mole of NaOH should be the same as ALL neutralisations like this simplify to the same ionic equation:  H+. + OH- = H2O. 

7 0
3 years ago
About system implementation in long<br>​
olga nikolaevna [1]

Answer:

Systems implementation & evaluation

What is systems implementation?

What are the tools for physical systems design?

What are the issues to consider before an information system is operational?

What are the key indicators of a quality system?

What are the techniques for systems evaluation?

Systems implementation is the process of:

defining how the information system should be built (i.e., physical system design),

ensuring that the information system is operational and used,

ensuring that the information system meets quality standard (i.e., quality assurance).

Systems design

Conceptual design – what the system should do

Logical design – what the system should look to the user

Physical design – how the system should be built

Physical system design using structured design approach:

à To produce a system that is easy to read, code, and maintain

1. Factoring: decomposition

2. Span of control: 9 subordinate modules

3. Reasonable size: 50-100 LOC

4. Coupling: minimize inter-module dependency

5. Cohesion: single module functionality

6. Shared use: multiple calls to lower level modules from different bosses

Structured design tools

· Organization of programs and program modules (structure chart)

· Processing logic specification in each module (pseudocode)

Structure chart – to show graphically

how the various program parts/modules of an information system are physically organized hierarchically

how the modules communicate with each other through data couple (data exchange) and flag (control/message)

how the modules are related to each other in terms of sequence, selection, and repetition

8 0
2 years ago
Other questions:
  • How many rows and columns does ms-excel 2007 have???
    10·1 answer
  • Question 12 (1 point)
    6·1 answer
  • When might be the best time to start saving for retirement?
    5·2 answers
  • All of the following are career pathways in the architecture and construction career cluster except
    5·1 answer
  • Kyle wants to access his school’s home page. How can he do this?
    8·2 answers
  • The function below takes two numeric parameters. The first parameter specifies the number of hours a person worked and the secon
    13·1 answer
  • Which line of code will eliminate the element “calculator” from an array of supplies?
    13·1 answer
  • How to be fluent in computer
    10·2 answers
  • Cuantos días tiene un año
    6·1 answer
  • Questic
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!