Code:
public class College //college class
{
public StudentAccount firstLabStudent, secondLabStudent; //first and second lab student member variables to College class
College(String firstName, String secondName, int firstId, int secondId) //constructor
{
firstLabStudent = new StudentAccount(firstName, firstId); //creating firstLabStudent object
secondLabStudent = new StudentAccount(secondName, secondId); //creating secondLabStudent object
}
public void printStudents() //printStudents print the information of first and second lab students
{
System.out.println("The first lab student: "+firstLabStudent.getName()+" "+firstLabStudent.getStudentNumber());
System.out.println("The second lab student: "+secondLabStudent.getName()+" "+secondLabStudent.getStudentNumber());
}
public static void main(String []args) //main method
{
College clg = new College("Frank White", "Jurgen Klopp", 2019001, 2019002); //creating a College object in main and printing the students info
clg.printStudents();
}
}
class StudentAccount //student account class
{
public String name; //name of student
public int studentNumber; //id of student
StudentAccount(String name, int id) //constructor of student account class
{
this.name = name;
this.studentNumber = id;
}
String getName() //returns name of the calling student object
{
return name;
}
int getStudentNumber() //returns student number of the calling student object
{
return studentNumber;
}
}
Code Screenshot:
Output:

Each and everything is explained in the comment section of the code.
Thank you! Hit like if you like my work.
Question 1 (4 mark): Implement a program with two classes according to the following UML diagram:...
Question 2 (3 mark): Write a program to implement the class Coffee according to the following UML diagram and description so that it can display as the output example. Coffee -energy: double -protein: double -fat: double +Coffee +Coffee _energy: double, _protein: double. _fat: double) Coffee(sourceCup: Coffee) -printNutrition Information(): void +main(String[] args): void REQUIREMENTS The program has three constructors: the first one is a default constructor, it initializes the 3 data fields (50.0, 1.5, 1.7) at default; the second initializes the...
What this Lab Is About: Given a UML diagram, learn to design a class Learn how to define constructor, accessor, mutator and toStringOmethods, etc Learn how to create an object and call an instance method. Coding Guidelines for All ments You will be graded on this Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc) Keep identifiers to a reasonably short length. Use upper case for constants. Use title case (first letter is u case)...
Write a program in Java according to the following specifications: The program reads a text file with student records (first name, last name and grade on each line). Then it prompts the user to enter a command, executes the command and loops. The commands are the following: "print" - prints the student records (first name, last name, grade). "sortfirst" - sorts the student records by first name. "sortlast" - sorts the student records by last name. "sortgrade" - sorts the...
Using Java coding, complete the following: This program should implement a LinkedList data structure to handle the management of student records. It will need to be able to store any number of students, using a Linked List. LinearNode.java can be used to aid creating this program Student should be a class defined with the following: • String name • int year • A linked list of college classes (college classes are represented using strings) • An...
please help
Write a simple program with Student class having STL list of Record's structure as a member. 1. Records of the Students are not accessible to the outside world. 2. Student shall output its standing (Freshman, Sophomore etc). 3. A Student can only be created with the name 4. A class can only be added if there is a class name and the passing grade. Driver program creates a Student, adds few classes to the Student's records, then prints...
Instructions: Consider the following C++ program. At the top you can see the interface for the Student class. Below this is the implementation of the Student class methods. Finally, we have a very small main program. #include <string> #include <fstream> #include <iostream> using namespace std; class Student { public: Student(); Student(const Student & student); ~Student(); void Set(const int uaid, const string name, const float gpa); void Get(int & uaid, string & name, float & gpa) const; void Print() const; void...
Write the functions needed to complete the following program as described in the comments. Use the input file course.txt and change the mark of student number 54812 to 80. /* File: course.cpp A student's mark in a certain course is stored as a structure (struct student as defined below) consisting of first and last name, student id and mark in the course. The functions read() and write() are defined for the structure student. Information about a course is stored as a...
This is the question:
These are in Java format.
Comments are required on these two Classes (Student.java
and StudentDemo.java) all over the coding:
Provide proper comments all over the
codings.
---------------------------------------------------------------------------------------------------------------
import java.io.*;
import java.util.*;
class Student {
private String name;
private double gradePointAverage;
public Student(String n , double a){
name = n;
gradePointAverage = a;
}
public String getName(){
return name;
}
public double getGradePointAverage(){
return gradePointAverage;
}
...
Write a C++ program that includes the following: Define the class Student in the header file Student.h. #ifndef STUDENT_H #define STUDENT_H #include <string> #include <iostream> using namespace std; class Student { public: // Default constructor Student() { } // Creates a student with the specified id and name. Student(int id, const string& name) { } // Returns the student name. string get_name() const { } // Returns the student id. int get_id () const { } // Sets the student...
Write a C++ console program that defines a class named Course that utilizes a dynamically allocated array. Do not use the vector class for this assignment. The Course class should define private data members for the name of the course, the number of students in the course, an array of student names (string*), and the capacity of the course (the array may not be full of students). Use pointer notation when dealing with the array. A 2-arg constructor should initialize...