Is there any better way to solve the way I'm calling employer() and get...() below codes in c++::
============
class employer{
string FirstName,
string LastName;
int emplID;
public:
///to set employer
void setemployer(string f,string l,int y)
{
FirstName=f;
LastName=l;
emplID=y;
}
string getFirstName(){
return FirstName;
}
string getLastName(){
return LastName;
}
int getemplID(){
return emplID;
}
....
// This sections is in the main:
int main()
{
string first;
string last;
int emplID;
for(int i=0;i<size;i++)
{
cin>>first>>last>>emplID; ///read data
employer[i].setemployer(first,last,emplID);
}
#include <iostream>
#include <string>
using namespace std;
class employer {
string FirstName;
string LastName;
int emplID;
public:
///to set employer
void setemployer(string f, string l, int y) {
FirstName = f;
LastName = l;
emplID = y;
}
string getFirstName() {
return FirstName;
}
string getLastName() {
return LastName;
}
int getemplID() {
return emplID;
}
};
int main() {
string first;
string last;
int emplID;
employer e;
cin >> first >> last >> emplID;
e.setemployer(first, last, emplID);
return 0;
}
Is there any better way to solve the way I'm calling employer() and get...() below codes...
"Function does not take 0 arguments". I keep getting this error for my last line of code: cout << "First Name: " << employee1.getfirstName() << endl; I do not understand why. I am trying to put the name "Mike" into the firstName string. Why is my constructor not working? In main it should be set to string firstName, string lastName, int salary. Yet nothing is being put into the string. #include<iostream> #include<string> using namespace std; class Employee { int...
8.26
Encapsulate the Name class. Modify the existing code shown below
to make its fields private, and add appropriate accessor methods to
the class named getFirstName, getMiddleInitial, and
getLastName.
code:
class Name {
private String firstName;
private String middleNames;
private String lastName;
//Constructor method
public Name(String firstName, String middleNames, String
lastName)
{
this.firstName = firstName;
this.middleNames = middleNames;
this.lastName = lastName;
}
//Accessor for firstName
public String getFirstName()
{
return firstName;
}
//Accessor for middleNames
public String getMiddlesNames()...
The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried to divide the code in 3 parts (Patient.h, Patient.cpp and Main.cpp), but it is giving me errors. Patient.h #ifndef PATIENT_H #define PATIENT_H #include <string> #include "Patient.cpp" using namespace std; class Patient{ private : string firstname; string lastname; string location; static int cnt; int id; public : Patient(string, string, string);...
In c++ redefine the class personType to take advantage of the new features of object-oriented design that you have learned, such as operator overloading, and then derive the class customerType. personType: #include <string> using namespace std; class personType { public: void print() const; //Function to output the first name and last name //in the form firstName lastName. void setName(string first, string last); //Function to set firstName and lastName according to the //parameters. //Postcondition: firstName = first; lastName = last...
What is wrong with this Code? Fix the code errors to run correctly without error. There are four parts for one code, all are small code segments for one question. public class StudentTest { public static void main(String[] args){ // Part Time Student Test Student ft1 = new PartTimeStudent("George", "Bush", "123-12-5678", 1, 2 ); System.out.println(ft1); Student ft2 = new PartTimeStudent("Abraham", "Lincoln", "001-90-5323", 6, 22 ); System.out.println(ft2); // Full Time Student Test Student pt1 = new FullTimeStudent("Nikola", "Tesla", "442-00-0998", 8, 26...
Please implement the following problem in basic C++ code and
include detailed comments so that I am able to understand the
processes for the solution. Thanks in advance.
// personType.h
#include <string>
using namespace std;
class personType
{
public:
virtual void print() const;
void setName(string first, string last);
string getFirstName() const;
string getLastName() const;
personType(string first = "", string last = "");
protected:
string firstName;
string lastName;
};
// personTypeImp.cpp
#include <iostream>
#include <string>
#include "personType.h"
using namespace std;
void...
JAVA PROGRAMMING In this final review lab from our intro course, use the Name class you created in the previous lab. In this lab, create a Student class with the following class variable: Student name: Name (Note: Name is a datatype) Student Id: String Create the getter and setter methods. In addition to these methods, create a toString() method, which overrides the object class toString() method. This override method prints the current value of any of this class object. Complete...
FOR JAVA: Summary: Create a program that adds students to the class list (see below). The solution should be named Roster402_v2.java. Allow the user to control the number of students added to the roster. Ask if the user would like to see their new roster to confirm additions. If yes, then display contents of the file, if no, end the program. ------------------------------------------------------------------------------------- List of student names and IDs for class (this will be your separate text file): Jones, Jim,45 Hicks,...
I don't really understand how to make the scores show up and how to make it start over. I honestly only half understand the things I've used to piece this together to make this work so far. but this is what I was asked to do..... read a user's first and last name read three integer scores, calculate the total and average determine the letter grade based on the following criteria - Average 90-100 grade is A, 80-89.99 grade is...
I have a little problem about my code. when i'm working on "toString method" in "Course" class, it always say there is a mistake, but i can not fix it: Student class: public class Student { private String firstName; private String lastName; private String id; private boolean tuitionPaid; public Student(String firstName, String lastName, String id, boolean tuitionPaid) { this.firstName=firstName; this.lastName=lastName; this.id=id; this.tuitionPaid=tuitionPaid; } ...