Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I know Java pretty well and my roommate needs help with her C programming homewo

ID: 3637813 • Letter: I

Question

I know Java pretty well and my roommate needs help with her C programming homework but I don't understand the syntax used in her programs. Can someone change these to java so I can help her? Thanks!

// Assignment #: 7

// Name:

// EmailAddress:

// Description: It displays a menu of choices

// (add volunteers, full time employees, or hourly employees,

// compute their pay, search a member, list members,

// quit, display menu) to a user.

// Then it performs the chosen task. It will keep asking a user

// to enter the next choice until the choice of 'Q' (Quit) is

// entered.

#include <iostream>

#include <string>

#include <cstdlib>

#include <vector>

#include "StaffMember.h"

#include "StaffMemberParser.h"

using namespace std;

void printMenu();

int main()

{

char input1;

string inputInfo;

bool operation;

vector<StaffMember *> memberList;

printMenu(); // print out menu

do

{

cout << "What action would you like to perform?" << endl;

cin >> input1;

switch (input1)

{

case 'A': //Add Member

{

cout << "Please enter a member information to add: ";

cin >> inputInfo;

StaffMember * newStaffMember = StaffMemberParser::parseStringToMember(inputInfo);

memberList.push_back(newStaffMember);

break;

}

case 'C': //Compute Pay

for (int j=0; j < memberList.size(); j )

{

memberList.at(j)->computePay();

}

cout << "pay computed ";

break;

case 'D': //Search for Member

cout << "Please enter a memberID to search: ";

cin >> inputInfo;

operation = false;

for (int j=0; j < memberList.size(); j )

{

if (inputInfo == memberList.at(j)->getMemberId())

{

operation = true;

}

}

if (operation == true)

cout << "member found ";

else

cout << "member not found ";

break;

case 'L': //List Members

if (memberList.size() == 0)

{

cout << "no member " << endl;

}

else

{

for (int j=0; j < memberList.size(); j )

{

memberList.at(j)->printInfo();

}

}

break;

case 'Q': //Quit

for (int j=0; j < memberList.size(); j )

{

delete memberList.at(j);

}

break;

case '?': //Display Menu

printMenu();

break;

default:

cout << "Unknown action ";

break;

}

} while (input1 != 'Q' && input1 != 'q'); // stop the loop when Q is read

}

/** The method printMenu displays the menu to a user **/

void printMenu()

{

cout << "Choice Action ";

cout << "------ ------ ";

cout << "A Add Member ";

cout << "C Compute Pay ";

cout << "D Search for Member ";

cout << "L List Members ";

cout << "Q Quit ";

cout << "? Display Help ";

}

______________________________________________________________

// StaffMember.h

// Assignment #: 7

// Name:

// Email Address:

// protections

#ifndef StaffMember_H

#define StaffMember_H

using namespace std;

class StaffMember

{

// protected variables

protected:

string firstName;

string lastName;

string memberId;

double pay;

// public functions

public:

StaffMember(string &string1, string &string2, string &string3)

{

firstName = string1;

lastName = string2;

memberId = string3;

pay = 0.0;

}

string getMemberId()

{ return memberId; }

virtual void computePay() = 0;

virtual void printInfo()

{ cout << " First name: " << firstName << " Last name: " << lastName << " Member ID: " << memberId << " Pay: $" << pay << " " << endl; }

};

#endif

Explanation / Answer

my friend this a pretty long as i told u the function is not overloaded here it is using pointers and the returned value by the function is a pointer the rest of the function is the same as jave if u need help converting the file there r 3 files in here and i can convert one for each question PLEASE Rate static StaffMember * parseStringToMember(string lineToParse) { const char *ptr = lineToParse.c_str(); char field [100]; int n, i = 0, hoursWorked; string type, firstName, lastName, employeeId; double rate, bonus; StaffMember * newMember; while ( sscanf(ptr, "%31[^/]%n", field, &n) == 1 ) { switch (i ) { case 0: type = field; break; case 1: firstName = field; break; case 2: lastName = field; break; case 3: employeeId = field; break; case 4: if ( type == "Volunteer" ) { newMember = new Volunteer(firstName, lastName, employeeId); return newMember; } else if ( type == "HourlyEmployee" ) { rate = convertToDouble(field); } else if ( type == "FullTimeEmployee" ) { rate = convertToDouble(field); } break; case 5: if ( type == "Volunteer" ) { // nothing to do } else if ( type == "HourlyEmployee" ) { hoursWorked = convertToInt(field); newMember = new HourlyEmployee(firstName, lastName, employeeId, rate, hoursWorked); return newMember; } else if ( type == "FullTimeEmployee" ) { bonus = convertToDouble(field); newMember = new FullTimeEmployee(firstName, lastName, employeeId, rate, bonus); return newMember; } break; default: break; } ptr = n; if ( *ptr != '/' ) { break; // didn't find an expected delimiter } while ( *ptr == '/' ) { ptr; // skip the delimiter } } }