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
Regarding the excerpt, what synthesized information helps spread a message to a large audience? Check all that apply. taking adv
frutty [35]

The question is incomplete! Complete question along with answer and step by step explanation is provided below.

Question:

Read the excerpt from News Articles about Bullying.

Aside from his website, Jaylen has appeared on numerous TV networks, chatted via Skype with college education students nationwide and spoken at the Florida Teachers Conference in Orlando in front of more than a thousand educators.

Regarding the excerpt, what synthesized information helps spread a message to a large audience? Check all that apply

1. taking advantage of technology

2. being good at public speaking

3. appearing on a television program

4. speaking mostly to college students

5. presenting at professional conferences

Answer:

The correct options are 1, 2, 3 and 5

Explanation:

In order to convey the message to a large audience, an individual can adopt certain measures that can ensure efficient spread of message.

Jaylen used technology (Skype) to chat with students nationwide, therefore, option 1 is correct.

Speaking in front of more than a thousand educators at the Florida Teacher Conference clearly suggests that Jaylen is good at public speaking, therefore, option 2 is correct.

Jaylen appeared on numerous TV networks as well as she presented at professional conferences which helps in spreading the message across a large audience, therefore, option 3 and 5 are also correct.

It is not necessary to speak to only college students, she can speak to students of all education levels to spread her message to large audience, therefore, option 4 is not correct.

7 0
3 years ago
What is powerpoint in a presentation?
Hitman42 [59]
Powerpoint is slides to your subject, whatever your sub is you can go to google slides and make you powerpoint there. you might have make a email account im not sure.

hope this helped!
4 0
2 years ago
Read 2 more answers
In the airline industry, frequent flyer programs, ticket kiosks, and e-ticketing are all examples of capabilities that are _____
crimeas [40]

Answer:

valuable; rare

Explanation:

A valuable capability is that which gives a firm some competitive advantage. Core competencies are the operational activities that a company does best. A business’s core competencies are what distinguish it from other rival companies in its industry. While Rare capabilities are capabilities that a small amount of, if any, competitors possess. Those type of capabilities that are costly or impossible to imitate.

from the above explanation we can deduce that the modern technology implementation in the airline industry has made it possible to have valuable ptograms and softwares for carring out several task which are no longer scarce to procure.

7 0
3 years ago
What are computer engineering algorithms?
Tom [10]
An algorithm<span> is a well-defined procedure that allows a </span>computer<span> to solve a problem. Another way to describe an </span>algorithm<span> is a sequence of unambiguous instructions. ... In fact, it is difficult to think of a task performed by your </span>computer<span> that does not use</span>algorithms<span>.</span>
5 0
3 years ago
If you attempt an edgeunity quiz is your latest attempt the one counted?
tekilochka [14]

Answer:

Hello

Explanation:

Hello profile picture of a nub how are you doing today?

8 0
3 years ago
Other questions:
  • Help?!<br> Does anyone know how to use Adobe SoundBooth?
    14·2 answers
  • An airline company would like to easily locate lost luggage. What technology would make it easier for them to locate the luggage
    6·2 answers
  • Example: An amount of $1,500.00 is deposited in a bank paying an annual interest rate of 4.3%, compounded quarterly. What is the
    5·1 answer
  • What is typically unique in each database table?
    5·2 answers
  • Shannon wants to work with renewable energy. She is researching what it would take to become a geochemist. A geochemist is someo
    8·1 answer
  • What cannot be performed using windows task manager
    10·1 answer
  • What is a neuromorphic chip?
    10·1 answer
  • . Write a toString method for this class. The method should return a string containing the base, height and area of the triangle
    10·1 answer
  • Does anyone know how to fix this???
    11·1 answer
  • 7 TH GRADE QUESTION...PLS HELP
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!