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
How fast is a backwards long jump in Super Mario 64?
Kamila [148]

Answer:

I honestly don't know if you're being serious or not as this was a popular thing a few years ago, there are a few videos on yt, one particularly from 2008 that answers your question pretty well.

Clipping through a loading area requires at least 400 speed. But if you're just interested in the usual speed, there are multiple glitches to make him go faster than his usual x3.5 increased running speed (which is the speed you get at the LEAST when BLJing) but it seems the average is  -200. I've seen people get up to -900 though, so.

Basically, it can vary. In a very specific area he can get max momentum of -9373, which is probably the fastest even though it's against a wall.

6 0
2 years ago
write query for all products reutrn product name with its amounts due, paid, canceled, and refunded, order the result by product
spayn [35]

Answer:

SELECT product_name, amount_due, amount_paid,

              cancelled, amount_refunded

   FROM products

ORDER BY product_name ASC;

Explanation:

SQL (Structured Query Language ) was used above.

The SELECT command is used to list all the variables we want in our output.

The FROM command signifies the location.

ORDER BY command ensures that your result is ordered

ASC means Ascending Order.

; signifies the end of the query.

NOTE: Underscores were used because variables cannot be written with spaces between them

8 0
2 years ago
1. Explain the difference between a web browser and a search engine. (2 points)
Elan Coil [88]

Answer:

1. A browser is used to access websites and web pages whereas a search engine is used to search for particular information.

2. Indexing is the process by which search engines organise information before a search to enable super-fast responses to queries.

3.Search engines are used to find specialized data rapidly whereas web directory is used to find a list of different sites.

4. The working behind the PageRank algorithm is that a page with a large number of in- links(a link from an important page) to it, then its outgoing links to other pages also become important. It gives more importance to back links of a web page and propagates the ranking through links.

5. Look for Sites from Established Institutions 2. Look for Sites with Expertise 3. Steer Clear of Commercial Sites 4. Beware of Bias 5. Check the Date 6. Consider the Site's Look 7. Avoid Anonymous Authors 8. Check the Links

Explanation:

5 0
3 years ago
Mike recently started using Google Display Ads to create a more automated approach to managing his campaigns. What's one automat
Marysya12 [62]

Answer:

Automated targeting

Explanation:

Display Automated Targeting is an automated targeting option within the Audience settings of the display campaigns that gives Google full right to show your ads to an audience that is “similar” to the one you specified.

8 0
2 years ago
What are the components that make a computer work?
Schach [20]

Answer: Plastic, metal, rubber, wiring, electricity, technology, wifi,  

Explanation: You need  PLASTIC to make a frame for the computer. METAL

to make an exoskeleton under the plastic frame. RUBBER to hold those loose wires and to make sure the electricity doesn't escape and shock you. ELECTRICITY to charge and make the computer runs.  Technology is used for you to log in and out of your computer and WIFI to make sure it doesn't lag.

8 0
2 years ago
Other questions:
  • What is the software called that allows the user to create, access, and manage a database? question 8 options:
    10·1 answer
  • Which one is not among standard creation committee?
    9·1 answer
  • Why is statistics important?
    6·1 answer
  • In a linked chain implementation of a queue, the performance of the enqueue operation
    10·1 answer
  • Which of the following are the dimensions of feasibility? Group of answer choices cost, schedule, technical, and organizational
    14·1 answer
  • Formatting means ____________
    12·2 answers
  • A period in which unemployment is low, business produces many goods and services, and wages are good is called ______.
    8·1 answer
  • Hello i need help whats -5 = 500
    13·2 answers
  • computer is an electronic machine that is used for data processing to produce meaningful information explain in statement​
    5·1 answer
  • If you're connected to a switch and your NIC is in promiscuous mode, what traffic would you be able to capture
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!