void read_into_array(ifstream &in)
{
// refer to the index where the current element is to be placd
int index = 0;
// loop untill the file ends
while(!in.eof())
{
// read element and store in s
in>>s[index];
index++;
}
}
Code Screenshot
4. Complete the code inside the box class dtype int id; float rate; int hours; public:...
code in C language ADT: typedef struct{ int ID; float salary; int age; }Employee; Specification: In this lab, five functions need to be implemented using the given ADT. 1. Employee* readRecord(FILE*) This function receives a FILE pointer created before. It reads a line from the provided csv file, and creates an Employee struct pointer with the information from that line then returns the pointer back to the calling function. Each line in the provided csv file contains the id, salary,...
Consider the Tollowing class declaration: class student record public: int age; string name; double gpa; }: Implement a void function that initiatizes a dynamic array of student records with the data stored in the file "university body.txt". The function has three formal parameters: the dynamic array "S db, the count, and the capacity. Open and close an ifstream inside the function. Remember, you must allocate memory for the initial size of the dynamic array using "new" inside this function. If...
Here is the code for the Infant class: public class Infant{ private String name; private int age; // in months public Infant(String who, int months){ name = who; age = months; } public String getName(){ return name;} public int getAge(){ return age;} public void anotherMonth() {age = age + 1;} } The code box below includes a live Infant array variable, thoseKids. You cannot see its declaration or initialization. Your job is to find out which Infant in the array...
A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS 210), credit hours (for example, 3), and a letter grade (for example, A). Include get and set methods for each field. Create a Student class containing an ID number and an array of five CollegeCourse objects. Create a get and set method for the Student ID number. Also create a get method that returns one of the Student’s CollegeCourses; the method takes an integer...
A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS 210), credit hours (for example, 3), and a letter grade (for example, A). Include get and set methods for each field. Create a Student class containing an ID number and an array of five CollegeCourse objects. Create a get and set method for the Student ID number. Also create a get method that returns one of the Student’s CollegeCourses; the method takes an integer...
A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS 210), credit hours (for example, 3), and a letter grade (for example, A). Include get and set methods for each field. Create a Student class containing an ID number and an array of five CollegeCourse objects. Create a get and set method for the Student ID number. Also create a get method that returns one of the Student’s CollegeCourses; the method takes an integer...
C++
Program 2 Consider a class Employee with data members: age (an integer), id (an integer) and salary (a float), and their corresponding member functions as follows: class Employee { private: int age; int id; float salary: public: Employee; // default constructor: age=0, id=0, and salary=0 void setAge(int x); // let age = x void setId(int x); // let id = x void setSalary(float x); // salary = x int getAge(); // return age int getId; // return id float...
Here is the code from the previous three steps:
#include <iostream>
using namespace std;
class Student
{
private:
//class variables
int ID;
string firstName,lastName;
public:
Student(int ID,string firstName,string lastName)
//constructor
{
this->ID=ID;
this->firstName=firstName;
this->lastName=lastName;
}
int getID() //getter method
{
return ID;
}
virtual string getType() = 0; //pure virtual function
virtual void printInfo() //virtual function to print basic details
of a student
{
cout << "Student type: " << getType() <<
endl;
cout << "Student ID: " << ID...
java
Given that class Zebra has a constructor with a header as follows: public Zebra(int age, int stripes) complete the following method. A try-with-resources is required. Method zebraCatalog reads all of the data from the file passed to parameter zebralist, creates a Zebra object for each line of data in the file, adding all of the zebra objects to the ArrayList passed to parameter zebras. Each line of data in the file consists of a zebra's age, a space and...
Java question
Consider the following code segment. public class KaBoom { public int b; public void m1 () {//Your code goes here } public void m2 (KaBoom k) { System, out. print In (k. b); } } Complete the method body of m1 () indicated by the comment line. The m1 () method simply calls the m2 () method by passing in the current KaBoom object variable to m2 ().